Learn how to create structured conversations using Pipecat’s flow system
NodeConfig
, and may contain the following properties:
name
: The name of the node; used as a reference to transition to the node.role_messages
: A list of message dicts
defining the bot’s role/personality. Typically set once in the initial node.task_messages
: A list of message dicts
defining the current node’s objectives.functions
: A list of function call definitions and their corresponding handlers.pre_actions
: Actions to execute before LLM inference. Actions run once upon transitioning to a node.post_actions
: Actions to execute after LLM inference. Actions run once after the node’s initial LLM inference.context_strategy
: Strategy for updating context during transitions. The default behavior is to append messages to the context.respond_immediately
: Whether to run LLM inference as soon as the node is set. The default is True.task_messages
, as your bot always needs a prompt
to advance the conversation.dicts
:
role_messages
at initialization for those LLMs.task_messages
and reference the available functions. The LLM will use these functions to complete the task and signal when it’s ready to move forward.
For example, if your node’s job is to collect a user’s favorite color:
FlowsFunctionSchema
that works across all LLM providers:
handler
where you implement your application logic and specify the next node:
NodeConfig
for Flows to transition to nextNone
for the next node. Other handlers may only want to transition conversational state without doing other work, in which case you can return None
for the result.
FlowsFunctionSchema
definitions while maintaining the same functionality.
pre_actions
execute immediately when transitioning to a new node, before the LLM inference begins.post_actions
execute after the LLM inference completes and any TTS has finished speaking.tts_say
: Speak a phrase immediately (useful for “please wait” messages)end_conversation
: Gracefully terminate the conversationfunction
: Execute a custom function at the specified timingrespond_immediately
field.
respond_immediately=False
may be particularly useful in the very first node,
especially in outbound-calling cases where the user has to first answer the
phone to trigger the conversation.respond_immediately=False
, the user may not
be aware of the conversational task at hand when entering the node (the bot
hasn’t told them yet). While it’s always important to have guardrails in your
node messages to keep the conversation on topic, letting the user speak first
makes it even more so.FlowManager
instance and calling initialize()
to start the conversation.
NodeConfig
into the initialize()
method:
initialize()
does not take any args.flow_manager.state
dictionary. This persistent storage lets you share data across nodes throughout the entire conversation.
Basic usage
FlowConfig
. This follows the same rules as the NodeConfig, but is assembled as a single JSON object that defines the entire state of the program.
See the food_ordering example for a complete FlowConfig implementation.