This component will start a nested flow (sub-flow).
https://docs.meya.ai/docs/flows#flow-component
Here is an example of a flow calling another flow:
triggers:
- keyword: agent
steps:
- say: I'll need to get your details first.
- flow: flow.get_user_info
- say: Great! Thank you for you info (@ user.name )
- say: I'll now transfer you to a human agent.
...
Flow file stored in flow/get_user_info.yaml
steps:
- (name)
- ask: What is your name?
- user_set: name
- (email)
- ask: What is your email address?
- user_set: email
In the above example the first flow calls the flow reference path
flow.get_user_info
on the second step. The first flow will then pause
and wait for the nested flow, flow.get_user_info
, to complete before
continuing on to step three.
Flow reference path
A flow's reference path is simply the flow's file path where the
slashes /
are replaced with dots .
, and the file extension is dropped.
(If you're familiar with Python, a flow reference path is similar to a Python file's module path.)
Here are some example reference paths:
flow/faq/answers/component.yaml
becomes:flow.faq.answers.component
flow/routing.yaml
becomes:flow.routing
Flow call stack
The flow maintains a flow call stack to keep track all the parent flows,
and where to continue execution from.
Check the flow call stack section in the
Flows guide for more info.
Element details
type: meya.flow.component
class: FlowComponent
path: /meya/flow/component/component.py
signature: flow
Fields
field | description | required | signature | default | type |
---|---|---|---|---|---|
spec | Override the original spec for this element. | ○ | ○ | null | Spec |
context | Send context data with this component's event. | ○ | ○ | {} | dict |
sensitive | Mark this component's event as sensitive. This will encrypt the event if the Sensitive Data integration has been enabled. | ○ | ○ | false | bool |
triggers | Activate these dynamic triggers when the component runs. Check the component triggers guide for more info. | ○ | ○ | [] | list |
flow | This is the reference path to the flow that needs to be called. A flow's reference path is simply the flow's file path where the slashes / are replaced with dots . , and the file extension is dropped. (If you're familiar with Python, a flow reference path is similar to a Python files module path) | ◉ | ◉ | FlowRef | |
jump | This property tells the flow component to jump to a specific label step in the nested flow. By default, a nested flow will always start execution from the first step. | ○ | ○ | null | StepLabelRef |
data | This property allows you to pass any flow scope variables from the calling flow to the nested flow. (This is analogous to passing function parameters in a conventional programming language such as Python). | ○ | ○ | null | dict |
transfer | The property tells the calling flow whether or not to continue with the flow once the nested flow is complete. If set to true , the bot's flow control will be transferred to the nested flow, and the calling flow will be stopped. The default is false . | ○ | ○ | false | bool |
async | This property tells the flow component to execute the nested flow in parallel and continue with the calling flow immediately. The default is false . | ○ | ○ | false | bool |
bot | The is the reference path to the bot that you would like to run the nested flow for. In Meya you can configure multiple bots per app and then run flows as different bots. When running a flow as another bot, any bot events e.g. text.say, will be attributed to that bot with that bot's name and avatar. By default this property always assumes the primary/default bot if not specified. | ○ | ○ | null | BotRef |
thread_id | This property tells the flow component to execute the nested flow on another conversation thread. This generally used for advanced use cases where a bot needs to manage multiple conversation threads. | ○ | ○ | null | str |
Usage reference
Basic
triggers:
- keyword: meya.flow.component
steps:
- flow: flow.name
Full
triggers:
- keyword: meya.flow.component
steps:
- spec:
type: STRING
data:
STRING: ANY
timeout: 123
trigger_when: ANY
context:
STRING: ANY
sensitive: false
triggers:
- type: STRING
data:
STRING: ANY
timeout: 123
trigger_when: ANY
flow: flow.name
jump: STEP
data:
foo: bar
transfer: false
async: false
bot: element.name
thread_id: STRING