Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions guides/features/pipecat-flows.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -413,11 +413,11 @@ async def on_first_participant_joined(transport, participant):

<Note>For Static Flows, `initialize()` does not take any args.</Note>

## Cross-Node State
## Cross-Node Logic

Pipecat Flows supports cross-node state through the `flow_manager.state` dictionary. This persistent storage lets you share data across nodes throughout the entire conversation.
### State

**Basic usage**
Pipecat Flows supports cross-node state through the `flow_manager.state` dictionary. This persistent storage lets you share data across nodes throughout the entire conversation:

```python
async def record_favorite_color_and_set_next_node(
Expand All @@ -428,11 +428,25 @@ async def record_favorite_color_and_set_next_node(
Here "record" means print to the console, but any logic could go here;
Write to a database, make an API call, etc.
"""
flow_manager.state["color"] = args["color"]
flow_manager.state["color"] = args["color"] # Cross-node state setting
print(f"Your favorite color is: {args['color']}")
return args["color"], create_end_node()
```

### Functions

Pipecat Flows supports defining functions that are available across all nodes in your flow. They're defined in the same way as node-specific functions, but are passed into the FlowManager at initialization:

```python
flow_manager = FlowManager(
task=task,
llm=llm,
context_aggregator=context_aggregator,
transport=transport,
global_functions=[global_function_1, global_function_2], # Cross-node functions
)
```

## Usage Examples:

### Dynamic Flow (Recommended)
Expand Down