Chat Widget events

The following are events to which you can subscribe your chat widget.

Update:

Events with lowercase names are deprecated. Please migrate to the new event names to ensure compatibility.

Event type Description
token Issued when a user token is assigned.
open Issued the chat widget is opened.
close Issued the chat widget is closed.
chatEnd Issued when a chat session has ended.
submitInitialForm Issued when the initial form is submitted.
agentLeft Issued when the agent has left the conversation.
agentJoined Issued when the agent has joined the conversation.

Migration guide

If you're currently using the deprecated lowercase event names, update the code to use the new camelCase event names as shown below:

Old case New case
chatend chatEnd
submitinitialform submitInitialForm
agentleft agentLeft
agentjoined agentJoined

Example of usage:

Copy
Copied
SinchSdk.Chat.addEventListener('token', () => {
  SinchSdk.Chat.send('message');
});

How the chatEnd event works

The chatEnd event is triggered when a chat session has ended, either by the user or the agent. You can use this event to perform cleanup actions, show a feedback form, or notify the user that the conversation is over.

End chat session

For example, you might want to display a message or redirect the user when the chat ends:

Copy
Copied
SinchSdk.Chat.addEventListener('chatEnd', () => {
  // Show a message or perform cleanup
  alert('The chat session has ended.');
});
We'd love to hear from you!
Rate this content:
Still have a question?
 
Ask the community.