Documentation

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>
CallbackDescription
onChatMinimizeClickCalled when the user clicks on the chat minimize button
onChatLauncherClickCalled when the user clicks on the chat launcher
onChatEndClickCalled when the user ends the chat
onChatProactiveButtonClickCalled when the user clicks on a proactive button
analyticsCalled when Flow sends an Analytics event
onChatInitialisedCalled once the chat dialog is displayed
onBotMessageCalled when the bot sends a message. The message text is sent as a parameter to the function
onMessageFeedbackButtonClickCalled when the user provides feedback to a bot message. Called with the feedback the user gave
iframeDimensionsCalled when the dimensions of the chat dialog iframe when the chat initialises. Called with an object containing width/height properties
onCarouselSelectionCalled when the user makes a selection in the carousel. See the Carousel section below for more details
onCarouselDisplayCalled when a carousel is displayed. See the carousel section below for more details
onCSATPopoverCloseClickedCalled when the CSAT close button is clicked
onChatConversationStartedCalled when the conversation is started. The session id of the chat is passed to the callback
onCSATPopoverSubmitClickedCalled when the user clicks on the submit button in the csat feedback popover
onWidgetEmbeddedCalled when the widget is embedded and the launchWidget method is available
onChatInitialisedErrorCalled when the widget fails to initialise

What’s Next