Starting Flows
This page covers the different ways you can control when flows are started: using the Command Generator, by predicting intents, and by using flow guards.
Starting Flows
Flows can be triggered by one of the following Rasa components, the SingleStepLLMCommandGenerator, MultiStepLLMCommandGenerator, or the NLUCommandAdapter.
Both SingleStepLLMCommandGenerator
and MultiStepLLMCommandGenerator
use the descriptions of each of your flows,
the running conversation, and other context to decide when to start a flow. It's important to write clear and
distinct descriptions for each of your flows to help the LLM decide which flow to trigger,
or to issue a clarify command if the user hasn't provided enough information.
The NLUCommandAdapter
uses a predicted intent to start a flow.
In order to trigger a flow via the NLUCommandAdapter
you need to have an NLU trigger
defined for your flow.
Flow guards are conditions that have to be met before a flow can be started. Adding flow guards provides additional control over when flows are triggered.
NLU Trigger
The nlu_trigger
field is optional.
If present, it contains a list of intents that can start the flow.
If you don't want to use a confidence threshold, list the intent names:
If you only want the flow to trigger if the confidence is above a threshold, use the following syntax:
Multiple Intents in NLU Trigger
You can list multiple intents for the nlu_trigger
.
If any of these intents is predicted, the flow will be started by the
NLUCommandAdapter.
caution
In order to actually use nlu_trigger
, you need to add the
NLUCommandAdapter before the LLMCommandGenerator
to
your NLU pipeline in the config file.
Preventing Flows from Starting
Flow Guards
Flow guards are specified by adding an additional if
field to the flow definition.
For example, the following flow for showing the user's latest bill can only be triggered
if the slots authenticated
and email_verified
are both true
.
If the condition after the if
key is not met, the flow cannot be started. However, there
are some exceptions to this:
- The flow is triggered through a link step from another flow.
- The flow is triggered through a call step from another flow.
- The flow has defined intents with an NLU trigger. In this case, intent trigger messages,
for example
/initialize_conversation
, can "force start" a flow for a targeted intent.
If you have a flow which should exclusively be started via a link
or call step, you can specify that by adding if: False
.
For example: