Other Methods
Other Methods
InfoCall these methods after the chat has loaded and the
readyevent has fired.
A message from an operator
Sends a chat message to the visitor as a message from an operator. For example, you can send a different automatic message on each page of your website. The message exists in this browser only: it does not reach the server, and operators do not see it in the Tidio panel.
tidioChatApi.messageFromOperator('Message from operator!');A message from a visitor
Sends a message from the visitor to the operator. For example, a button on your page can use it to start a conversation about the issue the visitor needs help with.
tidioChatApi.messageFromVisitor('Message from visitor!');Popup open
Opens the chat window. The effect is the same as when the visitor clicks the chat widget on your page. If the pre-chat survey is enabled, the visitor must fill in its fields before the first message sends.
tidioChatApi.open();Popup close
Closes the chat window. The effect is the same as when the visitor clicks the hide icon at the top of the chat window.
tidioChatApi.close();
InfoThe
openandclosemethods also fire the events of the same name. Do not call them inside listeners for those events, or your code loops.❌ Don't:
window.tidioChatApi.on('close', function () { window.tidioChatApi.close(); });
Show or hide the widget
Takes the whole chat widget off the page, or puts it back.
tidioChatApi.hide();
tidioChatApi.show();You can call them before the chat loads. A hide() keeps the widget off the page, and the widget appears when you later call show().
display(shouldDisplay) does the same from a boolean: display(true) is show(), display(false) is hide(). Use it when the decision is computed, as in the Project status example below.
InfoHiding the chat widget through tidioChatApi does not stop chatbots from triggering.
While the widget is hidden, nothing from it is visible or audible. A chatbot can still run and can open the conversation inside the widget, so the widget can already be open when you later call show().
Project status
Returns the current status of your project: 'online' when your operators are available, 'offline' when they are not. The status follows the working hours and the operator availability that you set in the Tidio panel.
tidioChatApi.getStatus();The method takes no arguments and returns the value at once. Before the chat finishes loading it returns null. Inside a ready listener it always returns a status.
To show the widget only when your project is online, read the status when the chat loads, then follow the setStatus event for later changes.
tidioChatApi.on('ready', function () {
tidioChatApi.display(tidioChatApi.getStatus() === 'online');
tidioChatApi.on('setStatus', function (status) {
tidioChatApi.display(status === 'online');
});
});Set the chat color
Changes the color of the chat widget. For example, you can set a different color on each subpage of your website.
tidioChatApi.setColorPalette('#333333');Clear the conversation
Empties the visitor's message list in this browser. The visitor stays the same, so the next message continues the same conversation with the same operator.
tidioChatApi.clearMessages();The conversation empties in place. The widget is not reloaded and stays usable. The unread count resets, and the clear drops pending attachments and a message that was typed but not sent. Every other open tab of the same browser empties its conversation too.
After a page reload the widget does not show the cleared messages again: it remembers how far the clear reached and keeps everything up to that point hidden. The one exception is a message that the server had not confirmed yet when you called. If the page closes before that confirmation arrives, the message can come back.
If a message bubble is on screen, it closes the same way the close button closes it, so the beforeClose and close events fire. The widget writes the saved data at once, so a call from a beforeunload handler still lands. A call made before the ready event waits and runs after the widget boots.
InfoThe clear works on this browser only. Operators still see the whole conversation in the Tidio panel, and the same visitor still sees it on another device. To drop the visitor identity as well, use
resetVisitor.
Reset the visitor
Removes all widget data of this browser, drops the visitor identity and starts the widget again as a new anonymous visitor. Use it when a user logs out of a shared browser, so that the next user cannot see the previous conversation.
Remove or replace your identify data before the call. The restart reads document.tidioIdentify again. If the previous user's data is still on the page at that moment, the widget identifies the new visitor as that user, and the reset undoes itself.
// user A logs out
delete document.tidioIdentify;
tidioChatApi.resetVisitor();
// the next user logs in
document.tidioIdentify = { distinct_id: 'user-b', email: '[email protected]' };The widget state becomes the state of a first visit: no messages, no unread count, no pre-chat data, and the chat closed.
The widget leaves the page while the restart runs, and comes back when the new visitor is registered. It comes back complete, with your colors and your settings. It never appears in a default look. The connection closes at once and opens again shortly after. The new connection registers the new visitor and fires the ready event again.
A widget that you hid with tidioChatApi.hide() stays hidden. Resetting the visitor and hiding the widget are separate things, so the reset does not show it again. If you call tidioChatApi.show() while the widget is away, the widget appears when the new visitor is registered.
Every other open tab of the same browser restarts too, and as the same new visitor: its widget leaves the page and comes back, its conversation empties, its connection restarts, and its ready event fires again. An open chat or a message bubble closes the same way the close button closes it, so the beforeClose and close events fire in every tab that had one open.
The widget removes the data at once, so a call from a beforeunload handler still wipes it. The restart that follows does not finish on a page that is unloading, so a user who leaves the page does not become a new contact in your Tidio panel.
InfoThe reset works on this browser only. The server keeps the conversations of the previous visitor and operators still see them in the Tidio panel. To empty only the message list and keep the visitor, use
clearMessages.
Updated 7 days ago