Skip to main content

This tutorial builds a complete voice agent for a restaurant. By the end you will have a working agent that greets callers, collects a reservation, and confirms the details.

You will use the ADK to define the agent, iterate on it, and push it for testing. Merging and deployment still happen in Agent Studio.

What you will build

The agent handles calls to Maison, a fictional restaurant. When a caller asks to make a reservation, the agent:
  1. Enters a booking flow and collects the caller’s name, party size, and preferred date and time
  2. Confirms the details back to the caller
  3. Stores the booking on the conversation state

What you will learn

This tutorial covers:
  • creating a new project and pulling it down locally
  • working on a branch
  • defining entities for structured data collection
  • building a multi-step flow with default steps and a function step
  • writing a start function and a booking function
  • triggering a flow from a topic
  • tuning speech recognition with keyphrase boosting and transcript corrections
  • adjusting spoken output with pronunciation rules
  • previewing changes with poly status and poly diff
  • pushing and testing with poly chat

Prerequisites

  • the ADK installed and you’re signed in — see Getting started if you haven’t already

Part 1 — Set up the project

Create the project

This creates a new project in Agent Studio and initializes it locally in one step — see Getting started for how project creation works in general, and poly project for the full set of flags.
The project starts with just the base agent settings and voice configuration — see Working locally for what a full project structure looks like. Resources like config/entities.yaml, flows/, and topics/ don’t exist yet; you’ll create them as you go.

Create a working branch

You are now on the booking-flow branch — pushes go here instead of main, leaving it untouched until you merge. See Branches, push, and pull for why this matters.
Check which branch you are onRun poly status at any time to see your current branch, region, and when the project was last pulled.

Part 2 — Define the agent

Persona

Open agent_settings/persona.txt and describe who the agent is. This is the free-text field Agent Studio shows as Role:
Keep identity and behavior separateThe persona says who the agent is. Standing instructions about what it should do belong in rules.txt below.
Supported referencesThe persona accepts {{attr:...}} and {{vrbl:...}} references, so it can vary per variant or per call. Behavioral references such as {{fn:...}} and {{ho:...}} belong in rules.txt.

Rules

Open agent_settings/rules.txt. Rules give the agent standing instructions that apply across every turn. Add the following:
{{fn:start_booking_flow}} references a global function you will define later. The model uses these references to understand when to call them.
{{fn:...}} only works for global functionsOnly functions in the top-level functions/ directory can be referenced with {{fn:...}} in rules and topics. Flow function steps (files inside flows/{name}/function_steps/) are called automatically by the flow — they cannot be referenced this way.

Part 3 — Define the entities

Entities are the structured data values the agent can collect from a caller. Create config/entities.yaml:
These four entities will be collected across the steps of the booking flow.
Automatic ASR biasingWhen a default step lists these entities in extracted_entities, the platform automatically configures speech recognition to be more accurate for that kind of input — dates, times, numbers, and names.

Part 4 — Build the booking flow

Flows live under flows/. Each flow gets its own directory. The directory name must be the snake_case version of the flow’s name field — so a flow named Booking Flow must live in flows/booking_flow/. Create the directory structure:

Flow configuration

Create flows/booking_flow/flow_config.yaml:

Step 1 — Collect name

Create flows/booking_flow/steps/collect_name.yaml:

Step 2 — Collect party size

Create flows/booking_flow/steps/collect_party_size.yaml:

Step 3 — Collect date and time

Create flows/booking_flow/steps/collect_date.yaml:
child_step: confirm_booking uses the Python filename (without .py) rather than a step name — that is the convention for pointing to a function step.

Step 4 — Confirm booking (function step)

Function steps are deterministic Python. They run without model interpretation. Create flows/booking_flow/function_steps/confirm_booking.py:
After this function runs, the model receives the returned context string and uses it to continue the conversation.

Part 5 — Add a global function to enter the flow

Global functions live in the top-level functions/ directory. Create functions/start_booking_flow.py:
This is what {{fn:start_booking_flow}} in your rules resolves to. When the model decides to call it, the agent enters the booking flow at its start step.

Part 6 — Add a start function

The start function runs once at the beginning of every call, before the first user input. Use it to initialize state. Create or update functions/start_function.py:

Part 7 — Add a topic

Topics tell the agent what kinds of caller utterances map to which actions. Create topics/make_a_reservation.yaml:
The model uses content and example_queries to understand when this topic applies, and actions to know what to do.

Part 8 — Tune speech recognition

Voice agents listen on a noisy channel, and domain-specific vocabulary is usually the first thing ASR gets wrong. The ADK exposes two speech-recognition resources that do not require any code: keyphrase boosting and transcript corrections. Both live under voice/speech_recognition/.

Keyphrase boosting

Create voice/speech_recognition/keyphrase_boosting.yaml:
The recognizer biases toward these phrases when it is uncertain. Boost the brand name at maximum so the agent never mis-hears it, and apply lighter boosts to the phrases that disambiguate booking intent.

Transcript corrections

Spoken times and numbers often come through in forms that are hard to parse. Create voice/speech_recognition/transcript_corrections.yaml:
These rules are applied after the recognizer returns text but before the model sees it. They only touch the transcript — the caller’s audio is unaffected. See the speech recognition reference for the full field list, interaction styles, and barge-in settings.

Part 9 — Adjust how the agent speaks

Response control sits on the other side of the conversation: it shapes what the agent says before TTS. For a French-brand restaurant, the most common issue is pronunciation. Create voice/response_control/pronunciations.yaml:
You can add entries for any word or phrase the TTS mispronounces. See the response control reference for the full field list, including phrase filtering.

Part 10 — (Optional) Send an SMS confirmation

SMS is an enterprise featureSMS templates require an enterprise Agent Studio account. Skip this part if you’re on a self-serve account.
Skip this part if you are only testing via chatconv.send_sms_template needs conv.caller_number, which is only populated on the voice channel. In poly chat, the template won’t actually be dispatched — but the code path is wired the same way and will fire the moment a real call comes in.

Define the template

Create config/sms_templates.yaml:
The {{vrbl:...}} placeholders pull from conv.state values — so the function step has to set them before sending.

Send it from the function step

Replace the body of flows/booking_flow/function_steps/confirm_booking.py with:
Because the decision to send happens in Python, the model doesn’t need to resolve {{twilio_sms:...}} at all. See the SMS templates reference for the full field list, environment-specific sender numbers, and the conv.send_sms helper for free-form messages.

Part 11 — Review your changes

Variables in poly statusThe variables/ entries appear because the ADK scans your function code for conv.state.* assignments and tracks each one as a variable. These entries are virtual — they do not correspond to files on disk and are not something you need to create or manage. This is expected output.
Run poly diff to see the exact content difference for any file before pushing.

Part 12 — Push to Agent Studio

The agent is now deployed to the booking-flow branch. Sandbox remains on main and is unaffected.

Part 13 — Test on the branch

poly chat defaults to --environment branch, which chats against your current branch’s last pushed state — exactly what you just pushed, without touching main:
Useful chat flags
  • poly chat --state — prints conv.state after each turn so you can verify values are being set correctly
  • poly chat --functions — shows which functions the model called each turn
  • poly chat --push — pushes your latest changes before starting the session, useful during rapid iteration
poly chat --push can create conflict markersIf the remote state has diverged from your local copy, poly chat --push may write merge-conflict markers (<<<<<<<, =======, >>>>>>>) directly into your YAML files. If this happens, open the affected file, resolve the conflict by hand, and push again before continuing.
Keep editing, pushing, and chatting against the branch until you’re happy with the behavior. Only merge once it works the way you want.

Part 14 — Merge to main

Merge from the CLI with poly branch merge '<commit message>' (run from the booking-flow branch), or open the project in Agent Studio, switch to the booking-flow branch, and merge through the web UI:
See poly branch merge for the full conflict-resolution flow, including --interactive and --resolutions.

Part 15 — After the merge

poly branch merge switches you back to main locally and pulls the merged state automatically — there’s no separate poly branch switch or poly pull needed. Merging into main also deploys to sandbox automatically, so there’s no separate deploy step either. To confirm:
Then chat against sandbox to see the merged agent in action:
YAML key order changes after a round-tripAfter a push and pull, the platform returns YAML with keys in alphabetical order. Fields you wrote in logical order (such as name: before description:) will be reordered. This is cosmetic and does not affect behavior, but poly diff will show changes after the first round-trip even when the content is the same.

What to explore next

This tutorial covered a single flow with four steps. From here you can extend the agent in several directions. Multi-location support with variants: If Maison has multiple locations, use config/variant_attributes.yaml to define per-location phone numbers, opening hours, and capacity limits. The agent reads the right values for each location at runtime using {{attr:...}} in prompts and conv.variant.attribute_name in code. Handling cancellations: Add a second topic and flow for callers who want to cancel or modify a reservation. The flow structure is similar — collect a name or reference, confirm the record, then update state. External API calls: Replace the stub booking logic in confirm_booking.py with a real HTTP call to your reservation system. Function steps are the right place for this — they run deterministically and can store results in conv.state for the model to reference. Richer error paths: Add an explicit error step to the flow for when the booking cannot be completed. Route to it from confirm_booking.py using flow.goto_step("Error") and return a context string explaining what happened. Call handoffs: Define SIP transfer destinations in config/handoffs.yaml and trigger them from code with conv.call_handoff(...). Like SMS, handoffs require an enterprise Agent Studio account. See the handoffs reference.

Build an agent with the ADK

The general CLI and AI-agent workflows this tutorial applies to a concrete example.

Flows

Full reference for flow configuration, step types, and conditions.

Entities

All entity types and their configuration fields.

Functions

How global functions, transition functions, and function steps differ.

Topics

How topics connect caller intent to agent actions.

Speech recognition

Keyphrase boosting, transcript corrections, and ASR settings.

Response control

Pronunciations and phrase filtering for spoken output.

Variants

Per-location configuration without duplicating your project.
Last modified on November 27, 2026