Triggering Flows With User Input
Start a sequence of actions in response to a user's input.
As you've already seen, flows can be triggered by a user if your bot is able to grasp the user's intent and match it with an appropriate flow. Let's take a look at how you can do that.
Setting a flow trigger
When you're editing a flow, you'll see a Trigger field above the code editor. If no trigger has been set, there will be a button prompting you to add a trigger.
Clicking this button brings up a window where you can choose from a number of trigger types. Selecting an option reveals settings appropriate for that trigger type. The keyword trigger, for example, has two settings: keyword and ignorecase.
All trigger types have an optional priority setting. This can be used to resolve conflicts when a user's input matches more than one trigger.
For a full list of trigger types and their settings, visit the Triggers page.
Example
From the trigger type drop-down, select keyword. Set the keyword to hi
and click OK.
In the flow code editor, click the Hello World Template button. You should see this code appear in the code editor:
states:
first:
component: meya.text
properties:
text: Hello, World!
Click Save. In the test chat window to the right of the code editor, type hi
. Your bot should respond Hello, World!
.
The only downside of using this trigger is that it requires the user to enter the word hi
. No other greeting will trigger this flow. The more input your bot is able to understand, the easier it will be for users to interact with your bot. Let's get your bot to respond to a wider variety of greetings.
Starting a conversation with a bot is such a common use-case, Meya provides a built-in trigger type that uses Natural Language Understanding to detect different types of greetings. Re-open the Trigger window, select greetings from the trigger type drop-down. There are no settings to worry about, so go ahead and click OK. Save your bot and test it out in the test chat area.
This brief example demonstrates how your users can trigger flows (i.e. sequences of related actions), but what if you want to trigger a flow without the user's input? That's what we'll look at next.
Updated over 6 years ago