Overview

The Dixa Messenger emits events that you can listen to in order to react to what is happening within the messenger. For example if you want to know when a the widget is opened by the user, or when a conversation is started, you can use the API below to do so.

API

To listen to an event you should use the _dixa_.addListener() API, which receives two arguments, first is the event name and the second is the callback that will be called once the event has happened. In order to remove an event listener you can use the _dixa_.removeListener() API. The signature is exactly the same.

Here's a list of available events:

Event Description payload
on-widget-open-changed called when widget is either opened or closed by the user or programmatically boolean info
on-conversation-started called when a conversation is started object info
on-conversation-ended called when a conversation is ends object info
on-message-added called when a new message is added to the conversation, by the user, agent or bots ReceivableMessages info
on-view-changed called when user navigates to different viewing the messenger string info
on-user-identity-changed called when users identify themselves Identify info
on-agent-assigned called when an agent joins the conversation Agent info
on-agent-unassigned called when an agent leaves the conversation Agent info
on-user-purged called when the user identity is removed programmatically void
on-widget-focus-changed called when the widget is focused or loses focus string info
on-shutdown-completed called when the widget has finished the shutdown process void info
on-backend-error called when the backend has returned an error in response to an action BackendError info
user-banned called when user is banned via agent interface void
user-unbanned called when user is unbanned via agent interface void

Example:

Copy
Copied
function handleConversationStarted(data) {
  console.log(data.conversationId);
}

// start listening to the events
_dixa_.addListener('on-conversation-started', onConversationStarted);

// stop listening to the events:
_dixa_.removeListener('on-conversation-started', onConversationStarted);

Interface: HostNotificationEvents

Events that a host website can listen to. This is kept separate from WidgetEvents definitions in order to avoid any coupling of internal types to what we expose to the host.

To see a complete list of all available events and their corresponding payloads you can see the HostNotificationEvents interface.