CX Agent Studio: flows, routes and instructions
CX Agent Studio steers customer conversations with instructions and hands fixed procedures to flows, the page-by-page state machines of Dialogflow CX. Learn when each fits, predict which route or handler fires, and write structured instructions.
Chapter 2Low-code agentsLesson 2 of 3ShowHide
Chapter 2 of 7 in Google Cloud Professional Agentic Architect
- CX Agent Studio: flows, routes and instructionsYou're here
Prerequisites: The Google Cloud agent platform map
Two ways to steer a customer conversation
CX Agent Studio, part of Gemini Enterprise for Customer Experience, builds customer-facing agents for chat and voice. It gives you two ways to control what the agent does:
- Instruction-based agents. You write instructions; the model reads them each turn and decides what to say and which tools or other agents (sub-agents) to use. This handles open conversation well, and it is where working out what the customer wants belongs.
- Flows (flow-based agents). A is a state machine built in Dialogflow CX and imported into CX Agent Studio. The conversation moves from page to page by rules you wrote, so the same inputs always take the same path.
An instruction-based agent acts as the steering layer. It hands the conversation to
a flow when a fixed procedure is needed, passing values in as session
parameters (named values the conversation remembers, such as balance_due), and
takes over again when the flow reaches its end (END_SESSION), receiving the
flow's output parameters. To the agent the flow is a black box: everything goes in
and out through those parameters.
Google's guidance is to use flows for highly deterministic logic: collecting and validating data in a fixed order, or authenticating a customer on session parameters. Use the model for understanding what the customer wants, and callbacks (small pieces of code) for fixed, canned replies.
See the difference on one call below. Before you step through it, predict which design is sure to stop after the third wrong answer, then watch what each does when the customer goes off script, and how the flow counts each attempt.
Explain it: both designs carry the same rule, "allow two retries". In the flow, what makes the third wrong answer end the verification on every run, and what would you have to change for it to allow a fourth? In the instruction-based agent, what applies the limit?
Put it together
Find what enforces the limit
In One call, two ways to steer it, step to Try 3. Name the route that fires and the condition that makes it fire, then say which box on the instruction side would have to apply the same limit.
Apply it to a SIM swap
A mobile operator's SIM swap collects the account number, then a one-time code sent by text, and stops after three failed codes. Sketch it as flow pages: the pages in order, the retry route and its condition, and the stop route.
Split the call
The same customer also asks why the bill went up. Say which part stays with the instruction-based agent, which part goes to the flow, and which session parameters the agent passes in and gets back.
Inside a flow: pages, routes and handlers
A flow models one topic, such as taking a payment. Its states are , and exactly one page is current at any moment. Every flow has a start page, which becomes current when the flow starts.
Each page carries state handlers, the rules that decide what happens next:
- A has an intent
requirement, a condition requirement, or both. An intent is a named category
of what a customer means, such as
confirm.yes, recognised from example phrases; a condition is an expression over parameters, such as$session.params.balance_due > 0. A route's fulfillment (the reply or actions it runs) can answer the customer, and its transition target moves the conversation to another page. - An responds to an event. The common
ones are
sys.no-match-default(the input matched no intent in scope) andsys.no-input-default(the customer said nothing). Every flow has no-match and no-input handlers, created with it and impossible to delete, so the agent always has a fallback reply.
Routes and handlers can be attached to a page, or to the flow as a whole.
Scope: which handlers count right now
Only handlers in scope are evaluated:
- the current page's own routes and event handlers;
- the flow's event handlers;
- the flow's routes, but with a catch: on the start page all of them are in scope, while on any other page only those with an intent requirement are.
That catch is easy to miss. A flow-level route with only a condition
(balance_due > 0, say) acts only while the start page is current. Once the
customer is on another page, it can be true and still never fire.
Order: who wins
After a customer turn, the in-scope handlers are evaluated in three phases:
- Routes with an intent: the page's, then the flow's, in the order listed.
- Routes with only a condition: the page's, then the flow's (start page only).
- Event handlers for any event raised: those on a parameter the page is collecting from the customer, then the page's, then the flow's.
A handler with a transition target ends the evaluation. One without a target adds its reply and evaluation continues. An intent is consumed by the first route that matches it, and so is an event; a condition is not consumed, so several condition routes can each run if none of them transitions.
Try it below on a flow that takes a payment, with balance_due set to 120. Its
flow-level routes are the condition route balance_due > 0, which sends the customer
to Collect amount, and an agent.handoff intent route to a person. Step from the start page
through three customer turns, and before the second, predict what happens on Confirm payment when
the reply matches nothing.
On the start page the condition route fires, because every flow-level route is in scope there. On Confirm payment the same route is still true but out of scope, so the no-match event falls to the page's own handler, and the flow's no-match handler is never reached. Asking for a person still works from that page, because flow routes with an intent stay in scope everywhere and are checked first.
Choosing what goes in a flow
Card verification is the classic case for a flow: ask for the date of birth, then the last four digits, check each against the record, allow two retries, and do it the same way every time. A flow guarantees that order and that count. Working out why the customer called, answering follow-up questions and choosing the next step stay with the instruction-based agent, which calls the verification flow when it needs it.
Writing instructions
Instructions steer the instruction-based agents. You can write them as plain text, but Google suggests an XML structure, which can help the model follow them, and the console's Restructure instructions button converts plain text into it:
<role>: the agent's core job.<persona>: its personality, tone and behaviour, with a<primary_goal>inside.<constraints>: rules it must follow.<taskflow>: the conversation as<subtask>elements, each a series of<step>elements with a<trigger>(what starts the step) and an<action>(what to do).<examples>: few-shot examples.
The task flow is how you give step-by-step guidance: each step says when it applies
and what to do, so the model works through the task in order rather than guessing.
In this example, Card verification is the verification flow from above, imported
as a flow-based agent. The handover itself is driven by the description you give the
flow when you import it, which tells the parent agent when to transfer control.
<role>You help customers of Acme Energy pay their bills.</role>
<persona>
<primary_goal>Take a payment or explain the balance, accurately and briefly.</primary_goal>
Friendly and plain-spoken. Never pressure a customer to pay.
</persona>
<constraints>
Always state amounts with the currency.
Only quote balances returned by {@TOOL: get_balance}.
</constraints>
<taskflow>
<subtask name="Payment">
<step name="Verify">
<trigger>The customer wants to pay.</trigger>
<action>Hand over to the Card verification flow.</action>
</step>
<step name="Take payment">
<trigger>Verification succeeded.</trigger>
<action>Confirm the amount, then call {@TOOL: take_payment}.</action>
</step>
</subtask>
</taskflow>Instructions reference the agent's resources by name: {@TOOL: name} for a tool
added to the agent, {@AGENT: name} for another agent, and a variable's name in
braces, such as {customer_name}, for a value the conversation holds. Google
recommends writing instructions in English for the best understanding.
are sample exchanges inside
<examples>, each with a user turn, a model turn and, where a tool is used, the tool
call and its output. Google's advice is to use them strategically:
- Start with clear instructions, and add examples only if instructions alone fail.
- Use them for a failure the model keeps repeating, a strict output format, or a decision too subtle for if-then rules.
- Use few. Too many and the agent overfits, copying the examples instead of reasoning; they show a pattern, they aren't a lookup table.
An agent should always read back the payment amount and wait for a yes before calling take_payment. Where does that behaviour belong in the XML instructions?
Test the agent, and let Gemini find issues
CX Agent Studio tests an agent with test cases of three kinds: golden cases replay an ideal conversation as a regression check, scenario cases simulate conversations from a user goal, and simulation cases give a simulated user an ordered list of goals. An evaluation run plays them and scores the results.
To get help with failures, select test cases, choose Run selected, and tick Find issues with AI. After the run, AI-based suggestions appear on the results page, along with a downloadable loss report that summarises how the agent performed and where to improve it; Ask Gemini opens a helper that starts from that report. Google recommends a run count of 3 or more for useful suggestions. The feature is in Preview and, at the time of writing, supports agent applications with a single agent.
Sources
Show 7 sourcesHide sources
| Source | Publisher | What it supports |
|---|---|---|
| Professional Agentic Architect exam guide (opens in a new tab) | Google Cloud | objective 1.1; retrieved 2026-11-17 |
| Flow-based agents (opens in a new tab) | Google Cloud | importing Dialogflow CX flows; input and output parameters; when to use flows, callbacks and the model; retrieved 2026-11-17 |
| Instructions (opens in a new tab) | Google Cloud | XML structure, Restructure instructions, few-shot guidance, references, formatting; retrieved 2026-11-17 |
| Pages (opens in a new tab) | Google Cloud, Dialogflow CX | pages as states, start page; retrieved 2026-11-17 |
| State handlers (opens in a new tab) | Google Cloud, Dialogflow CX | routes and event handlers, scope, evaluation order, built-in events; updated 2026-11-10, retrieved 2026-11-17 |
| Conditions (opens in a new tab) | Google Cloud, Dialogflow CX | session parameter syntax; retrieved 2026-11-17 |
| Evaluation (opens in a new tab) | Google Cloud | retrieved 2026-11-17: golden, scenario and simulation test cases; "Find issues with AI" in Preview, single-agent applications only, a run count of 3 or more recommended, suggested fixes and a downloadable loss report |
Suggested videos
Show 2 videosHide videos
Intro to Gemini Enterprise CX for developers (opens YouTube in a new tab)
Developer intro to CX Agent Studio covering instructions, nested tools for consistent procedures, and testing, matching instructions vs flows.
Note: Doesn't walk through pages, routes, handler scope or evaluation order.
A Deep Dive into Conversational AI Agents on Google Cloud (opens YouTube in a new tab)
Builds a flow-based conversational agent step by step, including debugging the routing.
Note: Uses the older Dialogflow CX and Customer Engagement Suite names. The concepts carry over, but the UI differs from CX Agent Studio.
Review
What is the difference between a transition route and an event handler?
Check yourself
A flow has a flow-level route with only the condition $session.params.balance_due > 0, leading to the payment page. A customer with a balance is on the Confirm address page, which has no condition routes of its own, and says nothing. What happens?