Listeners / Events

Listeners / Events

Fully loading Tidio Chat

(function () {
    function onTidioChatApiReady() {
        // Code after chat loaded
    }
    if (window.tidioChatApi) {
        window.tidioChatApi.on('ready', onTidioChatApiReady);
    } else {
        document.addEventListener('tidioChat-ready', onTidioChatApiReady);
    }
})();

This function triggers only when Tidio Chat is fully loaded. Once it's up, you'll be able to use the methods below.

Other events

Widget have other events using which you can subscribe with a listener.

EventWhen it firesPayload
readyThe chat has finished loadingnone
beforeOpenJust before the chat window opensnone
openThe chat window has openednone
beforeCloseJust before the chat window closesnone
closeThe chat window has closednone
messageFromVisitorThe visitor sent a message, a file, or a survey rating{ message, fromBot, type: "text" | "upload" | "satisfaction_survey_rating" }
messageFromOperatorA message arrived from an operator or a bot{ message, fromBot }
conversationStartThe visitor started a conversationnone
setStatusYour project went online or offline"online" or "offline"
preFormFilledThe visitor submitted the pre-chat survey{ form_data }
resizeThe widget changed size{ width, height, iframe }
chatTabClickThe visitor clicked the Chat tab on the home screennone
chatWithUsClickThe visitor clicked "Chat with us" on the home screennone
conversationBackButtonClickThe visitor went back from a conversation to the home screennone
conversationOptionsButtonClickThe visitor opened or closed the options menu{ type: "open" | "close" }
headerCloseHoverThe pointer entered or left the close button{ type: "on" | "off" }

The payload arrives as the callback argument.

tidioChatApi.on('messageFromVisitor', function (data) {
    console.log(data.message);
});

conversationStart will trigger on the first message from visitor which wasn't handled by an automation. Event can trigger again for the same visitor if his/her last message is older than 1 day.


Did this page help you?