Callbacks
Callbacks
Callbacks let you add custom behavior when specific events occur in the chat widget. To use them, define your callback functions inside the widget configuration on your page. Note that callbacks cannot be stored on the server-side config.
<script>
window.DG_CHAT_WIDGET_CONFIG = {
widgetId: 'xxxxx-xxxxxx-xxxxxxx-xxxxxx',
env: 'dev.us|eu|us',
callbacks: {
onChatMinimizeClick: () => {
console.log('user minimized chat');
}
}
}
</script>
Callback | Description |
---|---|
onChatMinimizeClick | Called when the user clicks on the chat minimize button |
onChatLauncherClick | Called when the user clicks on the chat launcher |
onChatEndClick | Called when the user ends the chat |
onChatProactiveButtonClick | Called when the user clicks on a proactive button |
analytics | Called when Flow sends an Analytics event |
onChatInitialised | Called once the chat dialog is displayed |
onBotMessage | Called when the bot sends a message. The message text is sent as a parameter to the function |
onMessageFeedbackButtonClick | Called when the user provides feedback to a bot message. Called with the feedback the user gave |
iframeDimensions | Called when the dimensions of the chat dialog iframe when the chat initialises. Called with an object containing width/height properties |
onCarouselSelection | Called when the user makes a selection in the carousel. See the Carousel section below for more details |
onCarouselDisplay | Called when a carousel is displayed. See the carousel section below for more details |
onCSATPopoverCloseClicked | Called when the CSAT close button is clicked |
onChatConversationStarted | Called when the conversation is started. The session id of the chat is passed to the callback |
onCSATPopoverSubmitClicked | Called when the user clicks on the submit button in the csat feedback popover |
onWidgetEmbedded | Called when the widget is embedded and the launchWidget method is available |
onChatInitialisedError | Called when the widget fails to initialise |
Updated 9 days ago