Skip to content
Last updated

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 typeDescription
tokenIssued when a user token is assigned.
openIssued the chat widget is opened.
closeIssued the chat widget is closed.
chatEndIssued when a chat session has ended.
submitInitialFormIssued when the initial form is submitted.
agentLeftIssued when the agent has left the conversation.
agentJoinedIssued 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 caseNew case
chatendchatEnd
submitinitialformsubmitInitialForm
agentleftagentLeft
agentjoinedagentJoined

Example of usage:

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:

SinchSdk.Chat.addEventListener('chatEnd', () => {
  // Show a message or perform cleanup
  alert('The chat session has ended.');
});