Bot Events are triggered when specific actions occur during bot conversation or when specific events are triggered on bot channels.
For example, when a user clicks the Get Started button to initiate a chat with your FB Messenger bot, it triggers the Facebook Welcome event. You can use this event to customize the welcome greeting such as personalizing it with the user’s first and last names, capturing additional information from user and updating backend systems.
Bot Behavior
Developers can define bot behavior when an event is triggered using one of the following options:
Run a task
Select a Dialog task (Standard or Hidden ) to be invoked when the event triggers. Once the event is triggered, the dialog starts executing. If it is interrupted because of other intent detections, the Hold and Resume settings come into play. During execution, if the selected Dialog is not published in the bot, the event is discarded.
In some cases, the Dialog may not be available to the user during a conversation for various reasons such as the task is not yet published or suspended or simply not assigned to the user. In such cases, the bot throws an error message that the task is not currently available for execution. Developers can preempt such situations by testing the bot in Debug mode. Debug Console shows full details about the error, including the reason for the nonavailability of the task.
Run a script
Define a JavaScript to run when the event triggers. The script can make use of all applicable components such as session, context objects, bot variables, and bot functions. You can also fix the code using the Debug mode.
Show a message
Define a simple or advanced message to the user when the event triggers. It supports all messaging formatting features available in the Bots Platform, including multiple messages with channel override options. Also, developers can define language-specific messages.
Event Types
You can configure the following events to trigger responses:
Event | Trigger |
Welcome Event | On receiving the first message from the user from any channel. |
Facebook Welcome Event | On receiving Welcome Event from Facebook Messenger. This event takes precedence over Welcome Event if both are configured for a bot. |
Telegram Welcome Event | On receiving Welcome Event from Telegram. This event takes precedence over Welcome Event if both are configured for a bot. |
On Connect | Every time a user invokes Web / Mobile SDK |
End of Conversation (Available post v7.1 release) |
On reaching end of conversation. See below for details. |
Task Execution Failure (Available post v6.40 release) |
On encountering an error in dialog task execution like:
|
RCS Opt-in Event (Available post v7.1 release) |
On receiving the message that a user has opted for RCS Messaging channel. |
RCS Opt-out Event (Available post v7.1 release) |
On receiving the message that a user has opted out of RCS Messaging channel. |
Configuration
Follow these steps to configure a bot event:
- On the bot main menu, from Natural Language > Default Conversations select Event Handlers.
- On the Events page, select one of the events. The Event Configuration window slides open.
- Select one of these options to define how to proceed when the selected event is detected:
- Initiate Task,
- Run Script,
- Show Message.
Additional Notes
Task Execution Failure Event
- This event is available from v6.40 release.
- By default, this event is always enabled with Show Message option. This event cannot be disabled.
- This bot-level behavior can be overridden for specific tasks by defining task-specific failure event from the dialog task settings. Refer here for how.
Welcome Event
Users can initiate bot conversations in varied ways, from a simple greeting to directly expressing an intent or asking an FAQ. To facilitate a scope for the developer to customize the bot response based on the user choice, the Welcome event comes with additional options when you choose Initiate Task or Show Message as the event configurations. For example, if the first user utterance maps to a bot task, should the bot execute the event-based task or the user intent first?
As a developer, you can define the bot priority when the user starts the bot conversation with a greeting, task, or FAQ from the options listed below:
Event Configuration | Options |
Initiate Task |
If the Task is unavailable to the user for any reasons such as the task is not yet published or suspended or simply not assigned to the user, in such cases, the bot throws an error message that the task is not currently available for execution. |
Show Message |
|
End of Conversation
Note: Introduced in ver7.1
End of Conversation is triggered when the bot is not expected to send any message to the user or receive any message from the user.
A new flag indicating the reason for ending the task, added to the end of task event, will help in deciding the end of conversation behavior. Client-side implementations of BotKits, RTM and Webhook channels can use this reason for task completion flag in the context, to determine an appropriate course of action.
On triggering this event, the context will be updated with the following details:
- Reason for triggering event (see the table below)
- Name of the task that has just ended. If its a FAQ then the task name will be given set to ‘FAQ’
Scenario | End of Conversation Flag |
Reached last node of the dialog | Fulfilled |
Task is cancelled by user | Cancelled |
Error in task or FAQs execution (without Task Failure Event, no hold tasks) | Failed |
Linked dialog completed without returning to parent dialog | Fulfilled_LinkedDialog |
On answering a FAQ | Fulfilled |
Successful event execution with Run Script or Show Message (no tasks on hold) | Fulfilled_Event |
Error in executing event with Run Script or Show Message (no tasks on hold) | Failed_Event |
User declines to resume on-hold task (when no other task is on hold | Cancelled |
IVR Impact
You may also use this event to define how and when the calls should be terminated for voice-based channels. The IVR implementation has been enhanced to enable the closure of the session/call only when the ‘end of conversation’ is completed. See here for how.