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.

PropertyDescriptionRequiredDefault
patternThe regex pattern to match.Yes
ignorecaseIgnore the case of the message.Notrue
capture_textStore the user's entire input, not just the portion that matched the regex pattern. If true, the input will be stored in flow.value.Notrue

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.

796

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:

351

Testing the regex intent.

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.

PropertyDescriptionRequiredDefault
keywordThe exact text the input must match.Yes
ignorecaseIgnore the case of the message.Notrue
796

The keyword intent.

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.

PropertyDescriptionRequiredNote
project_idFound in your Dialogflow agent's settings.YesEach agent requires its own Google Project.
languageA 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.
NoDefault: autodetect
intentThe name of the intent to match.No
intent_regexA regular expression to use to match incoming intent.No
max_confidenceThe maximum confidence between 0.0 and 1.0 that will trigger the intent.NoDefault: 1.0
min_confidenceThe minimum confidence between 0.0 and 1.0 that will trigger the intent.NoDefault: 0.67
cache_durationThe 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.NoDefault: 60

Data available in the flow scope

You can access details regarding the matched intent within within the flow scope.

ParameterDescription
flow._confidenceThe agent's confidence in the match.
flow._intentThe intent the agent matched.
flow.valueThe user's original text.
flow.fulfillmentThe agent's response, if you've provided the agent with responses, is located in flow.fulfillment.speech.
flow.parametersA simplified version of the query is available in flow.parameters.simplified.
flow.sourceThe 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.

PropertyDescriptionRequiredNote
client_access_tokenFound in your api.ai agent settings.Yes
languageThe 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.
Noex. en, ja, ar
intentThe name of the intent to match.NoMatches any intent.
intent_regexA regular expression to use to match incoming intent.NoUsed for advanced intent matching. Overrides intent name matching
min_confidenceThe minimum confidence between 0.0 and 1.0 that will trigger the intent.NoDefault: 0.667
max_confidenceThe maximum confidence between 0.0 and 1.0 that will trigger the intent.NoDefault: 1.0
cache_durationThe 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.NoDefault: 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.

328

The cancel intent in DialogFlow.

In your agent's settings, note your client access token.

1165

The agent's 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:

351

Testing the api_ai intent type.

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.

356

Testing the api_ai intent type.

This time, only the cancel intent will trigger the flow. The debug console confirms that start a new subscription didn't match.

233

Data available in the flow scope

You can access details regarding the matched intent within within the flow scope.

ParameterDescription
flow._confidenceThe agent's confidence of the match.
flow._intentThe intent the agent matched.
flow.valueThe user's original text.
flow.fulfillmentThe agent's response, if you've provided the agent with responses, is located in flow.fulfillment.speech.
flow.parametersA simplified version of the query is available in flow.parameters.simplified.
flow.sourceThe 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.

PropertyDescriptionRequiredDefault
tokenthe wit.ai access tokenYes
intentthe name of the wit.ai intent to matchNoMatches any intent.
intent_regexA regular expression to use to match incoming intentNoUsed for advanced intent matching. Overrides intent name matching
min_confidencethe minimum wit confidence between 0.0 and 1.0 that will trigger the intentNo0.667
max_confidencethe maximum wit confidence between 0.0 and 1.0 that will trigger the intentNo1.0
cache_durationThe 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.No60
token: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
intent: book_appointment
797

wit.ai

📘

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.

ParameterDescription
flow._confidenceThe agent's confidence of the match.
flow._intentThe intent the agent matched.
flow.valueThe user's original text.
flow.fulfillmentThe agent's response, if you've provided the agent with responses, is located in flow.fulfillment.speech.
flow.parametersA simplified version of the query is available in flow.parameters.simplified.
flow.sourceThe 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.

1112
PropertyDescriptionRequiredNotes
app_idFound in luis.ai appYes
api_keyFound in luis.ai appYes
intentthe name of the luis.ai intent to matchNoMatches any intent.
intent_regexA regular expression to use to match incoming intentNoUsed for advanced intent matching. Overrides intent name matching
min_confidencethe minimum wit confidence between 0.0 and 1.0 that will trigger the intentNoDefault: 0.667
max_confidencethe maximum wit confidence between 0.0 and 1.0 that will trigger the intentNoDefault: 1.0
cache_durationThe 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.No60
app_id: xxxxxxxxxxxxxxxxxxxxxxxxx
api_key: xxxxxxxxxxxxxxxxxxxxxxxx
intent: order_pizza
795

📘

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.

ParameterDescription
flow._confidenceThe agent's confidence of the match.
flow._intentThe intent the agent matched.
flow.valueThe user's original text.
flow.fulfillmentThe agent's response, if you've provided the agent with responses, is located in flow.fulfillment.speech.
flow.parametersA simplified version of the query is available in flow.parameters.simplified.
flow.sourceThe 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.

796
PropertyDescription
spaceThe name of a CMS space.Required
keyA particular key within the space.Optional
languageA language code.Optional. Default: en
min_confidenceThe minimum confidence required in order to trigger the flow.Optional. Default: 0.67
detect_languageIf 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_fallbackIf no match is found using NLU, use a basic keyword matching approach instead.Optional. Default: true
cache_durationPrevious 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.

796
PropertyDescription
detect_languageIf checked, will set flow.language to the language the input was written in.Optional. Default: false
confidenceThe 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_eventsIf 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.

352

📘

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.

795

The start_chat trigger 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.

PropertyDescription
current_page_urlThe 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_agentA string identifying the user's web browser and operating system.
referrer_page_urlThe URL of the page the user was at immediately prior to coming to the current page.
locationThe user's location based on their IP address. Includes lat, lng, timezone, city, state, and country.
browser_languageA 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.

798

The open_chat trigger 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.

PropertyDescription
current_page_urlThe 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_agentA string identifying the user's web browser and operating system.
referrer_page_urlThe URL of the page the user was at immediately prior to coming to the current page.
locationThe user's location based on their IP address. Includes lat, lng, timezone, city, state, and country.
browser_languageA 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

793

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.

799

video

Triggers when someone enters a video.

📘

Integration support

Supported on Messenger, Telegram, Kik, Twilio and API & Webhook.

798

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.

797

file

Triggers when someone uploads a file.

📘

Integration support

Supported on Messenger, Twilio, Telegram and API & Webhook.

798

location

Triggers when someone enters their location 📍.

📘

Integration support

Supported on Messenger, Telegram, Smooch and API & Webhook.

796