Skip to main content

Overview

Dynamic variables allow you to inject personalized data into your agent’s responses for each specific call. Using the {{variable_name}} syntax, you can create agents that adapt to different contexts while maintaining consistent conversation flows.

Common Use Cases

  • Personalized greetings: “Hello {{customer_name}}, thanks for calling!”
  • Context-aware responses: “I see you’re calling about order {{order_id}}
  • Dynamic routing: Transfer to different numbers based on {{department}}
  • Time-sensitive information: Reference {{appointment_date}} or {{deadline}}

Where Dynamic Variables Work

Dynamic variables can be used in:
  • Prompts: Agent instructions and personality
  • Begin message: Opening greeting
  • Tool configurations:
    • Custom function URLs
    • Tool descriptions
    • Property descriptions
  • Call handling:
    • Voicemail prompts and messages
    • Transfer call phone numbers
    • Warm transfer instructions
  • Webhook URLs: Both agent-level (webhook_url) and account-level webhook URLs support dynamic variables, so you can route events per call (for example, https://example.com/webhook?call_for={{customer_name}}).

Add & test dynamic variables

1

Add dynamic variables in your prompts

Dynamic variables are placeholders surrounded by double curly braces. For example:
Supported fields include a variable picker so you do not have to remember exact names:
  1. Type {{ where you want a variable. A dropdown opens listing variables that apply in that context (for example, default system variables plus variables defined for the agent or flow).
  2. Filter the list by typing more characters after {{.
  3. Choose a variable with Enter, a click, or Tab. The editor inserts the full placeholder and closes the braces, for example {{customer_name}}.
You can still type {{variable_name}} by hand in supported fields. The picker is optional.
2

Test your dynamic variables

Before deploying, test your dynamic variables using the web interface. You can also set test values for each variable in a simulation test case, so automated test runs resolve placeholders the same way real calls do.
Testing dynamic variables in dashboard
3

Configure agent-level default dynamic variables

You can set default values for dynamic variables at the agent level. Default variables serve as a fallback and will only be used when specific variables aren’t included in the call request.
Default dynamic variable values in agent settings
4

Implement in production

For Outbound Calls

When using the Create Phone Call API, set your variables in the retell_llm_dynamic_variables field. Note that all values must be strings:

For Inbound Calls

You can supply dynamic variables in the Inbound Call Webhook. More details are at the linked doc.
Important: All values in retell_llm_dynamic_variables must be strings. Numbers, booleans, or other data types are not supported.
The spaces around the variable name will be trimmed when evaluating the variable.

Default System Variables

Retell automatically provides these system variables - no configuration required:

Phone Call Variables

These variables are only available for phone calls:

Chat Variables

These variables are only available for chat sessions:

Contact Variables

When a phone call matches a contact by phone number, that contact’s fields are passed in as variables automatically. You get {{first_name}}, {{last_name}}, {{do_not_call}}, and one variable per custom contact field, named after the field. Nothing is passed when no contact matches, so write the prompt to read correctly without them. See contact memory for filling those fields from past conversations.

Nested Variables

Retell supports nested variables, you can use the following syntax to create nested variables:
Now if you have set my_timezone to America/Los_Angeles, this would evaluate to {{current_time_America/Los_Angeles }} first, and will then evaluate to the actual time, as this is a system default variable.

Handling Missing Variables

Default Behavior

When a dynamic variable has no assigned value, it remains in its raw form with the curly braces intact: Example:
  • Prompt: "Hello {{user_name}}, how can I help you today?"
  • If user_name is not provided: "Hello {{user_name}}, how can I help you today?"
  • If user_name is “John”: "Hello John, how can I help you today?"

Checking for Unset Variables

In Conversation Flow (Equations)

To check if a variable is set in conversation flow conditions:

In Prompts

To handle unset variables in your prompts, you can add conditional logic:

Best Practices for Missing Variables

  1. Set defaults at agent level: Configure fallback values in agent settings
  2. Use defensive prompting: Design prompts that work with or without variables
  3. Test thoroughly: Always test with both set and unset variables
  4. Document requirements: Clearly indicate which variables are required vs optional

🎦 Video Tutorial

Additional Resources