The following data attribute is used in the examples below:
Example 1: Start a bot when the widget is opened
On this page, a bot is started when the widget is opened.
Try it out, it uses the following code:
This works by listening to the widget:opened
event, and making a sendClientMessage
API function call, to
send a message as the contact. The message itself is constructed like this:
>cs BOTID COMMAND VARIABLE
The prefix to trigger bots is always '>cs'. With only the bot ID specified,
the conversation will be assigned to the bot.
If a 'command' and optionally a 'variable' are provided, these will be constructed
into a mention to the bot on behalf of the contact.
Example 2: Start a bot immediately, using static script tags
To load the widget and start a bot immediately, use the following html snippet
Example 3: Start a bot immediately, using dynamic script tags