Action Types
pre_actionsexecute immediately when transitioning to a new node, before the LLM inference begins.post_actionsexecute after the LLM inference completes and any TTS has finished speaking.
Built-in Actions
Pipecat Flows includes several ready-to-use actions for common scenarios.tts_say and end_conversation need no Python at all; function names a handler.
tts_say
Speak a phrase immediately (useful for “please wait” messages):- Declarative
- Programmatic
append_text_to_context to false:
- Declarative
- Programmatic
end_conversation
Gracefully terminate the conversation:- Declarative
- Programmatic
append_text_to_context to false to prevent that, the same way as for tts_say.
function
Execute a custom function at the specified timing. In a config,handler is the name of a callable in the handlers the Flow was constructed with; in code it is the callable itself:
- Declarative
- Programmatic
handlers.py
function action requires a handler; a config that omits one fails to load. The handler runs inline in the pipeline, queued behind the bot’s turn, which is what makes its timing predictable.
Custom Actions
You can define your own actions to handle specific business logic or integrations. In most cases, consider using a function action first, as it executes at the expected time in the pipeline. A custom action is a type Flows doesn’t provide. There are two ways to supply its code. Name a handler in the config. Like afunction action, but with your own type. The handler runs immediately when the node’s actions execute, rather than being queued in the pipeline:
handler in the config must be registered with register_action(), which is also how a programmatic flow supplies every custom action:
type and handler pass through to the handler on the action dict — channel and text above.
Action handlers should accept
(action, flow_manager). Single-argument
handlers (action) are deprecated and will be removed in 2.0.0.- Declarative
- Programmatic
Which Actions Need Python?
Action Timing
The execution order ensures predictable behavior:- Pre-actions run first upon node entry (in the order they are defined)
- LLM inference processes the node’s messages and functions
- TTS speaks the LLM’s response
- Post-actions run after TTS completes (in the order they are defined)