Trigger types
A comprehensive description of trigger types and their parameters
Every trigger type has an optional priority field. If a user's intent matches the trigger settings of two or more flows, the flow with the highest priority intent will be launched.
regex
Trigger the flow when the user's text input matches the regular expression. We recommend you use pythex to test your regular expressions.
Property | Description | Required | Default |
---|---|---|---|
pattern | The regex pattern to match. | Yes | |
ignorecase | Ignore the case of the message. | No | true |
capture_text | Store the user's entire input, not just the portion that matched the regex pattern. If true , the input will be stored in flow.value . | No | true |
Example
Create a new flow and copy-paste the following code into it.
states:
start:
component: meya.text
properties:
text: |
flow.value == {{ flow.value }}
flow.my_num == {{ flow.my_num }}
In the Trigger settings, choose the regex trigger type and enter the following pattern: (?P<my_num>\b[1-9][0-9]?\b)
. Leave the other settings at their defaults and click OK, then Save.
This flow will be triggered when someone enters a number between 0 and 100, even if that number is embedded in a string. The user's entire input is stored in flow.value
, while the regex group named my_num
is stored in flow.my_num
.
Test it in the test chat window:
keyword
Trigger the flow when the user's input exactly matches the keyword.
This trigger can be handy when testing and debugging your bot. For example, you may have hidden flows that print information pertinent only to developers. You can restrict access by using the keyword trigger type with a hard to guess keyword, like t3St1ng
.
In general, forcing users to guess the exact word or phrase that will trigger their intended flow creates a bad user experience. Use Natural Language Understanding when possible.
Property | Description | Required | Default |
---|---|---|---|
keyword | The exact text the input must match. | Yes | |
ignorecase | Ignore the case of the message. | No | true |
dialogflow
Uses third party NLU service Dialogflow to determine the user's intent and trigger the flow if a matching intent is found.
This trigger requires a Dialogflow v2 agent and the Dialogflow integration enabled. If you are using a v1 agent, upgrade your agent or use the
api_ai
trigger.
Property | Description | Required | Note |
---|---|---|---|
project_id | Found in your Dialogflow agent's settings. | Yes | Each agent requires its own Google Project. |
language | A 2-letter ISO 639-1 language code your Dialogflow agent supports. If left blank, the bot will auto-detect the user's language and set flow.language to the appropriate language code. | No | Default: autodetect |
intent | The name of the intent to match. | No | |
intent_regex | A regular expression to use to match incoming intent. | No | |
max_confidence | The maximum confidence between 0.0 and 1.0 that will trigger the intent. | No | Default: 1.0 |
min_confidence | The minimum confidence between 0.0 and 1.0 that will trigger the intent. | No | Default: 0.67 |
cache_duration | The number of seconds a request is cached. Set to 0 to force a new request. Note that shorter cache durations may increase latency in bot response since more API calls must be made. | No | Default: 60 |
Data available in the flow scope
You can access details regarding the matched intent within within the flow scope.
Parameter | Description |
---|---|
flow._confidence | The agent's confidence in the match. |
flow._intent | The intent the agent matched. |
flow.value | The user's original text. |
flow.fulfillment | The agent's response, if you've provided the agent with responses, is located in flow.fulfillment.speech . |
flow.parameters | A simplified version of the query is available in flow.parameters.simplified . |
flow.source | The source agent or domain. |
api_ai
Uses third party NLU service Dialogflow (formerly known as API.AI), to determine the user's intent and trigger the flow if a matching intent is found.
This trigger does not support Dialogflow v2 features, such as multi-language agents. If you wish to make use of those features, use the
dialogflow
trigger with your v2 agent.
Property | Description | Required | Note |
---|---|---|---|
client_access_token | Found in your api.ai agent settings. | Yes | |
language | The 2-letter ISO 639-1 language code of your model. If left blank, the bot will auto-detect the user's language and set flow.language to the appropriate language code. | No | ex. en , ja , ar |
intent | The name of the intent to match. | No | Matches any intent. |
intent_regex | A regular expression to use to match incoming intent. | No | Used for advanced intent matching. Overrides intent name matching |
min_confidence | The minimum confidence between 0.0 and 1.0 that will trigger the intent. | No | Default: 0.667 |
max_confidence | The maximum confidence between 0.0 and 1.0 that will trigger the intent. | No | Default: 1.0 |
cache_duration | The number of seconds a request is cached. Set to 0 to force a new request. Note that shorter cache durations may increase latency in bot response since more API calls must be made. | No | Default: 60 |
Example
In DialogFlow, create a new agent and set the language to English. Create two intents, cancel and subscribe. Give each intent 3-5 training phrases and test them out.
In your agent's settings, note your client access token.
Back in Bot Studio, create a new flow and copy-paste the code below.
states:
start:
component: meya.text
properties:
text: You triggered this flow!
For the Trigger type, select api_ai and paste your client access token. Enter en
as the agent's language. Leave the other fields with their default values, click OK, then Save.
Test the flow in the test chat window:
Note either Dialogflow intent will trigger the flow. This is because we didn't specify which Dialogflow intent we wanted to match. This is important to do since we may want to use the same NLU agent to trigger a cancel_subscription flow as well as a create_subscription flow.
Open the Trigger window again and enter cancel
in the intent field. Click OK, then Save. Now test the the flow again.
This time, only the cancel intent will trigger the flow. The debug console confirms that start a new subscription
didn't match.
Data available in the flow scope
You can access details regarding the matched intent within within the flow scope.
Parameter | Description |
---|---|
flow._confidence | The agent's confidence of the match. |
flow._intent | The intent the agent matched. |
flow.value | The user's original text. |
flow.fulfillment | The agent's response, if you've provided the agent with responses, is located in flow.fulfillment.speech . |
flow.parameters | A simplified version of the query is available in flow.parameters.simplified . |
flow.source | The source agent or domain. |
wit
Uses third party NLU service Wit.ai to determine the user's intent and trigger the flow if a matching trigger is found.
Property | Description | Required | Default |
---|---|---|---|
token | the wit.ai access token | Yes | |
intent | the name of the wit.ai intent to match | No | Matches any intent. |
intent_regex | A regular expression to use to match incoming intent | No | Used for advanced intent matching. Overrides intent name matching |
min_confidence | the minimum wit confidence between 0.0 and 1.0 that will trigger the intent | No | 0.667 |
max_confidence | the maximum wit confidence between 0.0 and 1.0 that will trigger the intent | No | 1.0 |
cache_duration | The number of seconds a request is cached. Set to 0 to force a new request. Note that shorter cache durations may increase latency in bot response since more API calls must be made. | No | 60 |
token: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
intent: book_appointment
Entities
Matched entities will be available on
flow
scope using the entity name and also as a list by appending_list
. For example the uttrance, "I love apples, pears and bananas." would result in the following flow scope data.{ "intent": "fruits" "fruit": "apples", "fruit_list": ["apples", "pears", "bananas"] }
Data available in the flow scope
You can access details regarding the matched intent within within the flow scope.
Parameter | Description |
---|---|
flow._confidence | The agent's confidence of the match. |
flow._intent | The intent the agent matched. |
flow.value | The user's original text. |
flow.fulfillment | The agent's response, if you've provided the agent with responses, is located in flow.fulfillment.speech . |
flow.parameters | A simplified version of the query is available in flow.parameters.simplified . |
flow.source | The source agent or domain. |
luis
Matches an intent hosted on third party service luis.ai. Create an account and host your intents and Meya will make API calls.
Example
Create an app on luis.ai.
Property | Description | Required | Notes |
---|---|---|---|
app_id | Found in luis.ai app | Yes | |
api_key | Found in luis.ai app | Yes | |
intent | the name of the luis.ai intent to match | No | Matches any intent. |
intent_regex | A regular expression to use to match incoming intent | No | Used for advanced intent matching. Overrides intent name matching |
min_confidence | the minimum wit confidence between 0.0 and 1.0 that will trigger the intent | No | Default: 0.667 |
max_confidence | the maximum wit confidence between 0.0 and 1.0 that will trigger the intent | No | Default: 1.0 |
cache_duration | The number of seconds a request is cached. Set to 0 to force a new request. Note that shorter cache durations may increase latency in bot response since more API calls must be made. | No | 60 |
app_id: xxxxxxxxxxxxxxxxxxxxxxxxx
api_key: xxxxxxxxxxxxxxxxxxxxxxxx
intent: order_pizza
Entities
Matched entities will be available on
flow
scope using the entity name and also as a list by appending_list
. For example the uttrance, "I love apples, pears and bananas." would result in the following flow scope data.{ "intent": "fruits" "fruit": "apples", "fruit_list": ["apples", "pears", "bananas"] }
Data available in the flow scope
You can access details regarding the matched intent within within the flow scope.
Parameter | Description |
---|---|
flow._confidence | The agent's confidence of the match. |
flow._intent | The intent the agent matched. |
flow.value | The user's original text. |
flow.fulfillment | The agent's response, if you've provided the agent with responses, is located in flow.fulfillment.speech . |
flow.parameters | A simplified version of the query is available in flow.parameters.simplified . |
flow.source | The source agent or domain. |
cms_nlu
If you've trained an NLU agent using Bot CMS, you can use the cms_nlu
trigger to handle intents returned by whichever NLU provider is connected to the CMS space.
Property | Description | |
---|---|---|
space | The name of a CMS space. | Required |
key | A particular key within the space . | Optional |
language | A language code. | Optional. Default: en |
min_confidence | The minimum confidence required in order to trigger the flow. | Optional. Default: 0.67 |
detect_language | If checked, attempt to determine the user's language and save it to flow.language . To save for long-term use, use meya.set to save flow.language to user.language . | Optional. Default: true |
use_keyword_fallback | If no match is found using NLU, use a basic keyword matching approach instead. | Optional. Default: true |
cache_duration | Previous responses from the NLU agent are cached for cache_duration .During development and testing it can be helpful to set this to 0 , which forces a new query to the NLU provider every time.Smaller values result in more API calls which can slow the bot down. | Optional. Default: 60 |
greetings
Greetings is a pre-trained NLP model (in English only) that can be used for your flows.
Intents
- hi
- how_are_you
- help
- whats_up
Example flow using the greetings trigger and auto routing.
route: true
states:
hi:
component: meya.random_text
properties:
responses:
- "Hey there! 😀"
- "Hi! 😃"
- "Howdy! 😃"
- "Hello! 😃"
return: true
how_are_you:
component: meya.random_text
properties:
responses:
- "I'm fine, thanks for asking 😃"
- Great! How are you?
- Super duper. You?
return: true
whats_up:
component: meya.text
properties:
text: Not much. What's up with you?
return: true
help:
component: meya.text
properties:
text: "Happy to help 😃"
return: true
catchall
A catchall trigger will launch the flow whenever a user says something that hasn't matched to any of your other triggers. A flow triggered by the catchall trigger can be used to activate a fallback conversation flow.
Property | Description | |
---|---|---|
detect_language | If checked, will set flow.language to the language the input was written in. | Optional. Default: false |
confidence | The default confidence value is very low so that the flow will only be triggered if no other trigger matches the user's intent. This is appropriate for a "fallback" flow.By setting the confidence to 1.0 and priority to 1 you can ensure this flow will always be triggered. | Optional. Default: 0.002 |
include_non_text_events | If checked, non-text user input will match the catchall trigger as well: locations, images, files, etc. | Optional. Default: false |
Example - Detect Language
You can use the catchall
trigger to detect a user's language. Start by creating a new flow language
. Paste the following code into the flow.
states:
first:
component: meya.text
properties:
text: "Your language is {{ flow.language }}"
The above code results in the following behaviour. Note that in the first interaction detect_language
is set to false
, while in the following three interactions it was set to true
.
Tip: use a catchall trigger in your customer service bot and then transfer the request to a live agent using the human.transfer component as the first state of your flow.
start_chat
Triggers when someone opens the Meya Web chat for the first time. Checks to see if the user has opened the chat before by referencing the specified key
. Optionally only fires on a URL specified in the settings.
Flow scope data
By default, the start_chat
trigger populates some flow
scope data, if available. If you want this data to persist beyond the current flow, use meya.set
, or a Python component, to save the data to the user
scope. Data on the flow
scope expires once the flow is complete.
Property | Description |
---|---|
current_page_url | The URL of the page from which the user is currently accessing the bot. If use_relative_path is checked in the trigger settings, this URL will be a relative URL instead of the full path. |
user_agent | A string identifying the user's web browser and operating system. |
referrer_page_url | The URL of the page the user was at immediately prior to coming to the current page. |
location | The user's location based on their IP address. Includes lat , lng , timezone , city , state , and country . |
browser_language | A string containing one or more language tags (sometimes referred to as a "locale identifiers") which are set by the user's browser in the Accept-Language HTTP request header.The string may also include a ;q= value, which can be used to show order of preference.For more information, refer to the MDN web docs. |
Here is a simple component that saves each of the above properties to the user
scope. The second tab demonstrates how to use the component in a flow.
# -*- coding: utf-8 -*-
from meya import Component
class Save(Component):
def start(self):
for key in ["current_page_url", "user_agent", "referrer", "location", "browser_language"]:
value = self.db.flow.get(key)
self.db.user.set(key, value or "")
return self.respond(message=None, action="next")
states:
save_data:
component: save_data
open_chat
Triggers anytime someone opens the Meya Web chat. Optionally only fires on a URL specified in the settings.
Flow scope data
By default, the open_chat
trigger populates some flow
scope data, if available. If you want this data to persist beyond the current flow, use meya.set
, or a Python component, to save the data to the user
scope. Data on the flow
scope expires once the flow is complete.
Property | Description |
---|---|
current_page_url | The URL of the page from which the user is currently accessing the bot. If use_relative_path is checked in the trigger settings, this URL will be a relative URL instead of the full path. |
user_agent | A string identifying the user's web browser and operating system. |
referrer_page_url | The URL of the page the user was at immediately prior to coming to the current page. |
location | The user's location based on their IP address. Includes lat , lng , timezone , city , state , and country . |
browser_language | A string containing one or more language tags (sometimes referred to as a "locale identifiers") which are set by the user's browser in the Accept-Language HTTP request header.The string may also include a ;q= value, which can be used to show order of preference.For more information, refer to the MDN web docs. |
Here is a simple component that saves each of the above properties to the user
scope. The second tab demonstrates how to use the component in a flow.
# -*- coding: utf-8 -*-
from meya import Component
class Save(Component):
def start(self):
for key in ["current_page_url", "user_agent", "referrer", "location", "browser_language"]:
value = self.db.flow.get(key)
self.db.user.set(key, value or "")
return self.respond(message=None, action="next")
states:
save_data:
component: save_data
Tip
Use the
open_chat
event to keep track of what web page the user is on. Pro tip: Use custom query params to trigger different flows.
start_voice_chat
Triggers every time a voice chat start without a specific invocation.
Integration support
Supported with Actions on Google
image
Triggers when someone enters an image. The image URL becomes available in flow.value
Integration support
Supported on Messenger, Telegram, Twilio, Kik, Smooch and API & Webhook.
video
Triggers when someone enters a video.
Integration support
Supported on Messenger, Telegram, Kik, Twilio and API & Webhook.
audio
Triggers when someone uploads an audio file.
Integration support
Supported on Messenger, Twilio, Telegram and API & Webhook. Telegram also supports a voice recorded message.
file
Triggers when someone uploads a file.
Integration support
Supported on Messenger, Twilio, Telegram and API & Webhook.
location
Triggers when someone enters their location 📍.
Integration support
Supported on Messenger, Telegram, Smooch and API & Webhook.
Updated almost 5 years ago