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. | Most common. Use when intent is not relevant. |
Auto | Automatically matches incoming | Useful for NLP applications in which you train multiple intents that get delegated to sub-flows. Also useful for nested flows with |
Advanced | Override the routing behavior to explicitly run a state based on the intent value. Use | Advanced applications where auto-routing is limited. |
Actions vs. IntentsOften the terms
intentandactionare 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
actionresults in anintentwith 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: trueAuto-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 / intentBy default if no action is specified intent will be set to the default value
start. You can usestartas 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 routingIf no matching intent is found, Meya will look at
route: true|falseto determine the state to run. Ifroute: false, the first state will run. Ifroute: true, no state will run.
Updated 5 months ago
