Variables represent values stored in conv.state and are discovered automatically by scanning function code.
How variables work
When you assign a value toconv.state.customer_name in code, customer_name becomes a tracked variable.
For example:
- global functions
- flow functions
- function steps
Why variables matter
Use variables to carry state across turns and reuse values in prompts, topics, and templates.Persist state
Store values that should survive across turns.
Drive prompts
Reference saved values in prompts and instructions.
Populate templates
Reuse state in SMS templates and other generated text.
Support logic
Let functions and flows branch based on previously stored values.
Setting state in code
Set variables by writing toconv.state:
Reading state in code
Read variables fromconv.state:
None.
Using variables in prompts and templates
Variables can be referenced in prompts, topic actions, SMS templates, and related text fields using either of these forms:{{vrbl:variable_name}}$variable_name
{{vrbl:variable_name}} is preferred because it is validated by the ADK.
Example in prompt text
Example in a template
Important rules
In prompts
Use:$variable{{vrbl:variable}}
conv.state.variable
For structured values
Do not use:$var.attribute
Best practices
- variables are discovered automatically, so no manual registration is needed
- use descriptive snake_case names
- initialize variables early, such as in
start_functionor near the beginning of a flow - keep variable names consistent across functions and prompts
- prefer
{{vrbl:...}}in user-facing text fields for better validation
Related pages
Functions
Learn where variables are typically created, updated, and read.
SMS templates
See how state variables are used in reusable text messages.

