Listen to events
Listen for when Webchat opens, closes, raises an error, and more.
You can listen to Webchat events within your website’s source code. This is useful if you want to:
- Make your website more responsive to Webchat
- Adjust UI elements depending on Webchat’s status
- Handle Webchat errors on your website
To listen any of the events on this page, just copy and paste the code snippet into your source code. Then, you can add whatever code you want — it’ll execute whenever the event fires.
You will need:
- A website with an embedded bot
- Familiarity with JavaScript
Webchat is ready
This event fires when Webchat is initialized and ready:
index.js
Webchat opens
This event fires when the Webchat window is opened:
index.js
Webchat closes
This event fires when the Webchat window is closed:
index.js
New conversation starts
This event fires when a new conversation starts in Webchat:
index.js
Message is sent
This event fires when either the user or the bot sends a message:
index.js
Error occurs
This event fires when the bot raises an error:
index.js
Custom event
This event fires when the bot triggers a custom event:
index.js