Skip to main content
This guide walks through the Hello World example — a two-node conversation flow where the bot asks for a favorite color, records the answer, and says goodbye. The flow is declarative: the graph lives in flow.yaml, the one tool it calls lives in handlers.py, and bot.py loads the config and joins the two.

Hello World Example

View the full source code on GitHub

Prerequisites

Pipecat Flows is included with Pipecat. Install Pipecat with the services used in this example:
You’ll need API keys for Cartesia (STT + TTS) and Google (LLM) set as environment variables:

The Flow

flow.yaml is the whole graph: two nodes, one tool, and the transition between them.
flow.yaml
Key by key:
  • initial_node names the node the conversation starts in.
  • nodes holds the flow’s nodes, keyed by name. The key is the node’s name, so initial and end are what transition_to refers to.
  • role_message sets the bot’s personality. It is sent as the LLM’s system instruction and persists across transitions until another node sets its own.
  • task_messages say what the LLM should do at this node.
  • functions lists the tools the node offers. Here, one entry names record_favorite_color and says that when it completes, the conversation moves to the end node.
  • post_actions run after the LLM responds. end_conversation gracefully terminates the call.
Note what the config does not contain: no description or parameters for record_favorite_color. Those come from the Python.

The Handler

handlers.py holds the Python the config names.
handlers.py
record_favorite_color is a direct function: its first parameter is flow_manager, the rest — here, color — become the tool’s parameters, and Flows derives the schema the LLM sees from the signature and the Google-style docstring. It returns a tuple of (result, TRANSITION_IN_YAML). The result is given to the LLM as context. TRANSITION_IN_YAML says the handler is not choosing where the conversation goes — the config’s transition_to decides that. Keeping transitions out of the Python is what lets the graph change without touching code.

The Bot

bot.py is a standard Pipecat pipeline plus four lines of Flows wiring:
bot.py
The four Flows lines:
  • FlowConfig.from_file reads and validates the YAML.
  • Flow(config, handlers=handlers) joins the config to the module holding the Python it names. handlers here is the imported module; a mapping of names to callables, or a list of modules, works too.
  • global_functions=flow.global_functions passes along the tools the config makes available at every node. This flow has none, so the list is empty, but wiring it up now means adding one later is a config-only change.
  • initialize(flow.initial_node) starts the conversation in the node the config named.
The config is validated as it loads, and constructing the Flow checks every reference it makes into your code. Starting the bot once is a complete check of the flow: a typo in a node name or a tool that doesn’t exist fails immediately, before any call comes in.

The Same Flow in Code

The same bot, written as a programmatic flow, is in examples/flows/python/hello_world.py. Read the two side by side to see what moves between the config and the Python.

Next Steps

Flow Configs

The full config format, loading, and validation

Functions

Node functions, edge functions, and branch tables

Examples

Explore more complex examples

API Reference

Complete technical reference