Pipecat Flows
Learn how to create structured conversations using Pipecat’s flow system
Pipecat Flows provides a framework for building structured conversations in your AI applications. It enables you to create both predefined conversation paths and dynamically generated flows while handling the complexities of state management and LLM interactions.
The framework consists of:
- A Python module for building conversation flows with Pipecat
- A visual editor for designing and exporting flow configurations
Key Concepts
- Nodes: Represent conversation states with specific messages and available functions
- Functions: Define actions and transitions (Node functions for operations, Edge functions for transitions)
- Actions: Execute operations during state transitions (pre/post actions)
- State Management: Handle conversation state and data persistence
When to Use Static vs Dynamic Flows
Static Flows are ideal when:
- Conversation structure is known upfront
- Paths follow predefined patterns
- Flow can be fully configured in advance
- Example: Customer service scripts, intake forms
Dynamic Flows are better when:
- Paths depend on external data
- Flow structure needs runtime modification
- Complex decision trees are involved
- Example: Personalized recommendations, adaptive workflows
Installation
If you’re already using Pipecat:
If you’re starting fresh:
💡 Want to design your flows visually? Try the online Flow Editor
Core Concepts
Designing Conversation Flows
Functions in Pipecat Flows serve two key purposes: interfacing with external systems and advancing the conversation.
Function Handlers
When you need to collect data, validate input, or retrieve information, add a handler to your function. These handlers are async functions that execute when the LLM calls the function, allowing you to interact with databases, APIs, or other external services:
Transitioning Between Nodes
To advance the conversation, Pipecat Flows offers two approaches based on your flow type:
For static flows, use the transition_to
property to specify the next node:
For dynamic flows, use a transition callback to determine the next node at runtime:
You can combine both approaches: use handlers to process data and transitions to advance the conversation, creating flows that are both functional and conversational.
Node Structure
Each node in your flow represents a conversation state and consists of three main components:
Messages
Messages set the context for the LLM at each state:
Functions
Functions come in two types, each serving a different purpose:
Node Functions with Transitions
Process data and optionally transition to a new state:
Edge Functions
Create transitions between states:
Actions
Actions execute during state transitions:
LLM Provider Support
Pipecat Flows automatically handles format differences between LLM providers:
OpenAI Format
Anthropic Format
Google (Gemini) Format
You don’t need to handle these differences manually - Pipecat Flows adapts your configuration to the correct format based on your LLM provider.
Implementation Approaches
Static Flows
Static flows use a configuration-driven approach where the entire conversation structure is defined upfront.
Basic Setup
Example Configuration
Transition Best Practices
- Use
transition_to
to make state changes explicit - Combine handlers with transitions when appropriate
- Keep transitions focused on single responsibilities
- Use clear, descriptive names for target nodes
- Validate all transition targets exist
- Test both successful and failed transitions
Dynamic Flows
Dynamic flows create and modify conversation paths at runtime based on data or business logic.
Basic Setup
Node Creation
Best Practices
- Keep state in flow_manager.state
- Create separate functions for node creation
- Handle errors gracefully in transitions
- Document state dependencies
- Test node creation and transitions thoroughly
Flow Editor
The Pipecat Flow Editor provides a visual interface for creating and managing conversation flows. It offers a node-based interface that makes it easier to design, visualize, and modify your flows.
Visual Design
Node Types
-
Start Node (Green): Entry point of your flow
-
Flow Nodes (Blue): Intermediate states
-
End Node (Red): Final state
-
Function Nodes:
- Edge Functions (Purple): Create transitions
- Node Functions (Orange): Perform operations
- Edge Functions (Purple): Create transitions
Naming Conventions
- Start Node: Use descriptive names (e.g., “greeting”, “welcome”)
- Flow Nodes: Name based on purpose (e.g., “collect_info”, “verify_data”)
- End Node: Conventionally named “end”
- Functions: Use clear, action-oriented names
Function Configuration
When using the Flow Editor, function handlers can be specified using the __function__:
token:
The handler will be looked up in your main script when the flow is executed.
When function handlers are specified in the flow editor, they will be exported
with the __function__:
token.
Using the Editor
Creating a New Flow
- Start with a descriptively named Start Node
- Add Flow Nodes for each conversation state
- Connect nodes using Edge Functions
- Add Node Functions for operations
- Include an End Node
Import/Export
Tips
- Use the visual preview to verify flow logic
- Test exported configurations
- Document node purposes and transitions
- Keep flows modular and maintainable
Try the editor at flows.pipecat.ai