Flow routing
Use a flow to route to sub-flows
Often either via an NLP model or external trigger (broadcast, parent flow) will invoke flows with an action
parameter set. This is interpreted as an intent
in the invoked flow. This intent
can be used to start at different states.
Use-case | Description | When to use |
---|---|---|
Default | The first state will be invoked independent of all action/intent params. Default is route: false | Most common. Use when intent is not relevant. |
Auto | Automatically matches incoming intent to a state with the same exact value. Matching states will be run first.Use route: true | Useful for NLP applications in which you train multiple intents that get delegated to sub-flows. Also useful for nested flows with action values being set. |
Advanced | Override the routing behavior to explicitly run a state based on the intent value. Use intents: {key/value map} | Advanced applications where auto-routing is limited. |
Actions vs. Intents
Often the terms
intent
andaction
are used interchangeably based on context.
- When invoking a flow, Meya uses the term
action
.- When training a NLU model, Meya uses the term
intent
.- From the flows context, Meya uses the term
intent
.In effect, an
action
results in anintent
with the same name.
1. Default routing
states:
# this `first` state will always run first
# independent of `intent` or `action`
first:
component: meya.text
properties:
text: "First."
second:
component: meya.text
properties:
text: "Second."
third:
component: meya.text
properties:
text: "Thirds."
return: true
Auto-routing: using intent / state matching
The following example handles the intents greeting
, upgrade
and cancel
. The state names have been constructed to match these intents.
route: true
states:
# the `state` exactly matching the `intent`
# will run first. if no `intent` was specified
# `start` state will run
start:
flow: main
return: true
greeting:
flow: greeting
return: true
upgrade:
flow: upgrade
return: true
cancel:
flow: cancel
return: true
Default action / intent
By default if no action is specified intent will be set to the default value
start
. You can usestart
as a default value to route to states.
Advanced routing
Manually specify the state that is run using a key/value map.
intents:
greeting: state1
upgrade: state2
cancel: state3
states:
# the `intents` map determines which state
# will run first
state1:
flow: greeting
return: true
state2:
flow: upgrade
return: true
state3:
flow: cancel
return: true
Using the route parameter in advanced routing
If no matching intent is found, Meya will look at
route: true|false
to determine the state to run. Ifroute: false
, the first state will run. Ifroute: true
, no state will run.
Updated over 6 years ago