Level 3 — Lesson 2 of 5 — Understand flows, steps, and transitions for structured multi-turn interactions.
For reference documentation on flows, see the Flows overview. This lesson focuses on how flows work and when to use them.
When to use flows vs other tools
Managed Topics
Simple question-and-answer. No sequencing needed.
Functions
Single actions: fetch data, call an API, save a value.
Flows
Multi-step sequences where order matters and the model must stay on track.
How flows work
A flow is a sequence of steps. Each step contains:- A prompt — instructions the model follows for this step
- Functions — scoped to this step only, used for transitions and actions
- A transition — how the flow moves to the next step (or exits)
Enter the flow
A start function calls
conv.goto_flow("flow_name"). This can be triggered from agent behavior, a knowledge base topic, or another function.Step activates
The step prompt is injected as a system message at the end of the conversation history. The model follows these instructions.
Model interacts with the user
The model asks for information, confirms details, or takes actions according to the step prompt.
The sticky prompt
The step prompt is always the last message in the conversation history. This is the most important thing to understand about flows. Unlike content returned from a function (which appears at a specific point in history and becomes less relevant as more turns happen), the step prompt is re-injected on every turn. It cannot be “forgotten” by the model.- Function content
- Flow step
Check your understanding
Creating and entering a flow
There are two ways to create a flow:- Go to Build → Flows and create one directly
- Create one from any behavior menu (e.g., inside a managed topic action)
- The flow itself (with a start step)
- A corresponding start function that contains
conv.goto_flow("flow_name")
Step transitions
Each step shows only its own functions to the model. When the model calls a flow function, that function can:- Save data (to
conv.state) - Call an API
- Move to the next step using
flow.goto_step("step_name") - Exit the flow using
conv.exit_flow()
- The previous step prompt is removed
- The new step prompt is injected
- Only the new step’s functions are visible
What happens without transitions
If you tell the model to ask for a phone number but don’t define what happens next, the model improvises. It may start asking for names, emails, or other details based on its training patterns. This is not a model failure — it is a design failure. You did not give it the next step.Exiting a flow
Whenconv.exit_flow() is called:
- The step prompt disappears from conversation history
- The model returns to normal behavior (agent rules, knowledge base, global functions)
- Any state saved during the flow persists in
conv.state
Try it yourself
Challenge: Design a two-step registration flow
Design a flow that collects a phone number and then a full name.Plan:
- What is the start step prompt?
- What flow function transitions from step 1 to step 2?
- What does the second step prompt say?
- How does the flow exit?
Hint
Hint
Each step should have a clear prompt (one instruction) and a flow function that saves the collected value and transitions. The final function should call
conv.exit_flow().Example solution
Example solution
Step 1 prompt: “Ask the user for the phone number we can contact them on. Once they provide it, call Step 2 prompt: “Ask the user for their full name. Once they provide it, call
save_phone_number.”Step 1 function (save_phone_number):save_name.”Step 2 function (save_name):
