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-caseDescriptionWhen to use
DefaultThe first state will be invoked independent of all action/intent params.
Default is route: false
Most common. Use when intent is not relevant.
AutoAutomatically 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.
AdvancedOverride 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 and action are used interchangeably based on context.

  1. When invoking a flow, Meya uses the term action.
  2. When training a NLU model, Meya uses the term intent.
  3. From the flows context, Meya uses the term intent.

In effect, an action results in an intent 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 use start 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. If route: false, the first state will run. If route: true, no state will run.