Chat History — UI Customization
Change the parts and the order of the two chat panels, and choose when each part shows.
The elements from the quick start are the whole chat UI, so you change it in
the HTML. Below we move and remove parts of the panels, change how the list
groups threads, and then use visible-when to show a line when the reader has
no chats yet.
You need a working chat page first. See Chat History — Quick Start.
Move, add and remove elements
<miso-history> and <miso-conversation> are the two containers. Each one
connects the Miso elements inside it to its workflow, so keep each element in
its own panel:
| Container | Elements you can put in it |
|---|---|
<miso-history> | <miso-new-thread>, <miso-threads>, <miso-error> |
<miso-conversation> | <miso-favorite> Since 1.14.2 ,<miso-title>, <miso-rename>, <miso-delete>, <miso-subscription>, <miso-messages>, <miso-query>, <miso-error> |
Inside a container, put the elements in any order, leave out the ones you do not want, and add your own HTML between them. This version puts the New chat button under the lists, and removes the subscription toggle and the delete button from the header:
<miso-history class="miso-history">
<section class="miso-history__group miso-history__group--favorite">
<h3 class="miso-history__group-title">Favorites</h3>
<miso-threads group="favorite"></miso-threads>
</section>
<section class="miso-history__group">
<h3 class="miso-history__group-title">Recents</h3>
<miso-threads group="unfavorite"></miso-threads>
</section>
<miso-new-thread></miso-new-thread>
</miso-history>
<miso-conversation class="miso-conversation">
<div class="miso-conversation__header" visible-when="nonempty">
<div class="miso-conversation__header-row">
<miso-favorite></miso-favorite>
<miso-title></miso-title>
<miso-rename></miso-rename>
</div>
</div>
<div class="miso-conversation__intro" visible-when="ready+empty">
What can I help with?
</div>
<miso-messages></miso-messages>
<miso-query visible-when="ready"></miso-query>
</miso-conversation>
Each thread in the list keeps its own star, and its menu to rename, subscribe
or delete. The SDK draws them as part of <miso-threads>, so these changes do
not touch them. Without <miso-favorite> in the header, the reader still stars
threads from the list.
Group the threads
Since 1.14.2
The group attribute of <miso-threads> chooses which threads that list
shows:
group | The list shows |
|---|---|
| Attribute left out | Every thread. |
favorite | The threads the reader starred. |
unfavorite | The threads the reader did not star. |
Each list loads and scrolls through its own threads, so put as many as you
need in one <miso-history>. Write group in the HTML, or set it before you
add the element to the page. A change after that has no effect.
For one list with every thread, starred or not:
<miso-history class="miso-history">
<miso-new-thread></miso-new-thread>
<miso-threads></miso-threads>
</miso-history>
The default layout styles the sections of the quick start by their class names:
| Class | Effect |
|---|---|
miso-history__group | A section with a gap above it. It is hidden when its list has loaded with no threads. |
miso-history__group--favorite | The section stays hidden until its list has a thread, also while it loads. |
miso-history__group-title | The small, uppercase heading of a section. |
These rules apply inside <miso-history class="miso-history"> only. With a
layout of your own, hide an empty section in your CSS.
Show a part at the right moment
The visible-when attribute shows an element only in the states it names. Put
it on a <miso-history> or a <miso-conversation>, or on an element inside
one.
| Value | Shows the element when |
|---|---|
initial | The workflow has not sent a request yet. |
loading | The request is out, and no data has arrived. |
ready | The data is arriving or has arrived. |
ongoing | The data is still arriving. |
done | All the data has arrived. |
erroneous | The request failed. |
empty | No Miso element in the container has data. |
nonempty | At least one Miso element in the container has data. |
- Separate values with spaces to show the element in any of them:
visible-when="initial loading". - Join a state to
emptyornonemptywith+to need both:visible-when="ready+empty". - Only the Miso elements that show data count toward
emptyandnonempty. The query box and the buttons do not. - The SDK shows the element with
display: block !important. To lay it out as a flex row or a grid, putvisible-whenon a wrapper around it.
The quick start uses it three times in <miso-conversation>:
| Element | visible-when | What the reader sees |
|---|---|---|
| The header | nonempty | The title and its buttons, once the open thread has messages. |
| The intro line | ready+empty | "What can I help with?", on a new thread with no messages. |
<miso-query> | ready | The question box, hidden while a thread loads. |
The header puts visible-when on miso-conversation__header, and lays out the
row on miso-conversation__header-row inside it. visible-when sets
display: block, so the flex row needs a wrapper of its own.
The thread list shows nothing when the reader has no chats. Add a line for that case:
<miso-history class="miso-history">
<miso-new-thread></miso-new-thread>
<p visible-when="ready+empty">Your chats show here.</p>
<section class="miso-history__group miso-history__group--favorite">
<h3 class="miso-history__group-title">Favorites</h3>
<miso-threads group="favorite"></miso-threads>
</section>
<section class="miso-history__group">
<h3 class="miso-history__group-title">Recents</h3>
<miso-threads group="unfavorite"></miso-threads>
</section>
</miso-history>
empty on <miso-history> counts every thread, whatever the group of each
list.
If it does not work
| Symptom | Cause |
|---|---|
The console shows … needs to be placed under a workflow container element | A Miso element is outside both containers. |
An element with visible-when always shows | The attribute name is wrong, or the element is outside both containers. The name is visible-when. |
| A flex row breaks into lines when it shows | visible-when sets display: block. Put it on a wrapper. |
A list ignores its group | The script set group after the element was on the page, or the page loads a release older than 1.14.2. |
Next
- API Configuration — how many threads load at a time, and which articles the answers can cite.
- Citation Links — the class, the attributes and the tooltip of each citation.
