Custom Initialization and Passing Metadata

By default the chatbot script is configured to show the chatbot on load. In cases you need customization on which pages does the chatbot show on or pass specific metadata you can override the trigger function and initialize the chatbot on your webpage.

You can find the Trigger Function under Features

Initializing the chatbot

The chatbot works based on events passed through the script. You can fire the following event to show the chatbot on a page. You can customize when the event is sent based on the origin, button click or any other action on the page to show the chatbot.

document.dispatchEvent(new CustomEvent("botWidgetInit", {"detail": {"origin": "support"}}));

Passing Metadata

To make decisions in the flow you can pass metadata to the chatbot. This metadata live in the conversation context and is available to use in routing/api and other actions.

let metadata = {
    "origin": "support",
    "tags": ["ios", "vip"]
}
document.dispatchEvent(new CustomEvent("botWidgetInit", {"detail": metadata}));

Last updated