---
updatedAt: 2026-08-19T07:33:38.000Z
agentTools:
  projectIndex: https://developers.tidio.com/llms.txt
---

# Listeners / Events

# Listeners / Events

## Fully loading Tidio Chat

```js
(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.

| Event                            | When it fires                                                | Payload                                                                          |
| -------------------------------- | ------------------------------------------------------------ | -------------------------------------------------------------------------------- |
| `ready`                          | The chat has finished loading                                | none                                                                             |
| `beforeOpen`                     | Just before the chat window opens                            | none                                                                             |
| `open`                           | The chat window has opened                                   | none                                                                             |
| `beforeClose`                    | Just before the chat window closes                           | none                                                                             |
| `close`                          | The chat window has closed                                   | none                                                                             |
| `messageFromVisitor`             | The visitor sent a message, a file, or a survey rating       | `{ message, fromBot, type: "text" \| "upload" \| "satisfaction_survey_rating" }` |
| `messageFromOperator`            | A message arrived from an operator or a bot                  | `{ message, fromBot }`                                                           |
| `conversationStart`              | The visitor started a conversation                           | none                                                                             |
| `setStatus`                      | Your project went online or offline                          | `"online"` or `"offline"`                                                        |
| `preFormFilled`                  | The visitor submitted the pre-chat survey                    | `{ form_data }`                                                                  |
| `resize`                         | The widget changed size                                      | `{ width, height, iframe }`                                                      |
| `chatTabClick`                   | The visitor clicked the Chat tab on the home screen          | none                                                                             |
| `chatWithUsClick`                | The visitor clicked "Chat with us" on the home screen        | none                                                                             |
| `conversationBackButtonClick`    | The visitor went back from a conversation to the home screen | none                                                                             |
| `conversationOptionsButtonClick` | The visitor opened or closed the options menu                | `{ type: "open" \| "close" }`                                                    |
| `headerCloseHover`               | The pointer entered or left the close button                 | `{ type: "on" \| "off" }`                                                        |

The payload arrives as the callback argument.

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

`setStatus` reports the status of your project. To get the status at load time, use [`getStatus`](https://developers.tidio.com/reference/widget-other-methods).

`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.