APPLIES TO: Composer v1.x and v2.x
In Bot Framework Composer, each dialog includes one or more event handlers called triggers. Each trigger contains one or more actions. Actions are the instructions that the bot will execute when the dialog receives any event that it has a trigger defined to handle. Once a given event is handled by a trigger, no further action is taken on that event. Some event handlers have a condition specified that must be met before it will handle the event and if that condition isn't met, the event is passed to the next event handler. If an event isn't handled in a child dialog, it gets passed up to its parent dialog to handle and this continues until it's either handled or reaches the bots main dialog. If no event handler is found, it will be ignored and no action will be taken.
To see the Create a trigger menu in Composer, select a dialog. Then select the three-dot menu on the right side and choose + Add new trigger from the dropdown menu.
Anatomy of a trigger
The basic idea behind a trigger (event handler) is "When (event) happens, do (actions)". The trigger is a conditional test on an incoming event, while the actions are one or more programmatic steps the bot will take to fulfill the user's request.
A trigger contains the following properties:
|The trigger name, which can be changed in the properties panel.
|The set of instructions that the bot will execute.
|The condition to be created or updated in the properties panel and is ignored if left blank, otherwise it must evaluate to true for the event to fire. Conditions must follow the adaptive expressions syntax. If the condition is ignored or evaluates to false, processing of the event continues with the next trigger.
A dialog can contain multiple triggers. You can view them under the selected dialog in the bot explorer. Each trigger shows as the first node in the authoring canvas. A trigger contains actions defined to be executed. Actions within a trigger occur in the context of the active dialog.
The screenshot below shows the properties of an Intent recognized trigger named Cancel that is configured to fire whenever the Cancel intent is detected as shown in the properties panel. In this example the Condition field is left blank, so no additional conditions are required in order to fire this trigger.
If you want to specify a confidence threshold for a specific intent, use the Condition field. In the above example, you could set a condition for this specific intent such as:
Types of triggers
There are different types of triggers that all work in a similar manner, and in some cases can be interchanged. This section will cover the different types of triggers and when you should use them. See the define triggers article for additional information.
Intent triggers handle events emitted by recognizers. After the first round of events is fired, the bot will pass the incoming message through the recognizer. If an intent is detected, it will be passed into the trigger with any entities contained in the message. If no intent is detected by the recognizer, an Unknown intent trigger will fire, which handles intents not handled by any trigger.
There are four intent triggers in Composer:
- Intent recognized
- QnA Intent recognized
- Unknown intent
- Duplicated intents recognized
You should use intent triggers when you want to:
- Trigger major features of your bot using natural language.
- Recognize common interruptions like "help" or "cancel" and provide context-specific responses.
- Extract and use entity values as parameters to your dialog.
For additional information see how to define triggers article.
Azure QnA Maker will be retired on 31 March 2025. Beginning 1 October 2022, you won't be able to create new QnA Maker resources or knowledge bases. A newer version of the question and answering capability is now available as part of Azure AI Language.
Custom question answering, a feature of Azure AI Language, is the updated version of the QnA Maker service. For more information about question-and-answer support in Composer, see Natural language processing.
Dialog events triggers
The base type of triggers are dialog triggers. Almost all events start as dialog events which are related to the "lifecycle" of the dialog. Currently there are four dialog events triggers in Composer:
- Dialog started (Begin dialog event)
- Dialog cancelled (Cancel dialog event)
- Error occurred (Error event)
- Re-prompt for input (Reprompt dialog event)
Most dialogs include a trigger configured to respond to the
BeginDialog event, which fires when the dialog begins. This allows the bot to respond immediately.
You should use dialog triggers to:
- Take actions immediately when the dialog starts, even before the recognizer is called.
- Take actions when a "cancel" signal is detected.
- Take actions on messages received or sent.
- Evaluate the content of the incoming activity.
For additional information, see the dialog events section of the article on how to define triggers.
Activities triggers are used to handle activities such as when a new user joins and the bot begins a new conversation. Greeting (ConversationUpdate activity) is a trigger of this type and you can use it to send a greeting message. When you create a new bot, the Greeting (ConversationUpdate activity) trigger is initialized by default in the main dialog. This specialized option is provided to avoid handling an event with a complex condition attached. Message events is a type of Activity trigger to handle message activities.
Here is a list of Activities triggers currently provided in Composer:
- Activities (Activities received)
- Greeting (ConversationUpdate Activity)
- Conversation ended (EndOfConversation activity)
- Event received (Event activity)
- Handover to human (Handoff activity)
- Conversation invoked (Invoke activity)
- User is typing (Typing activity)
- Message received (Message received activity)
- Command received (Command activity received)
- Command Result received (Command Result activity received)
- Message deleted (Message deleted activity)
- Message reaction (Message reaction activity)
- Message updated (Message updated activity)
You should use Activities triggers when a user begins a new conversation with the bot and when you want to take action on receipt of the following activity types:
You can create and emit your own events by creating an action associated with any trigger, then you can handle that custom event in any dialog in your bot by defining a Custom event trigger.
Bots can emit your user-defined events using Emit a custom event. If you define an Emit a custom event and it fires, any Custom event in any dialog will catch it and execute the corresponding actions.
For additional information, see the Custom events section in the How to define triggers article.