Dynamic variables
Pass runtime values to personalize your agent’s behavior.
Dynamic variables allow you to inject runtime values into your agent’s messages, system prompts, and tools. This enables you to personalize each conversation with user-specific data without creating multiple agents.
Overview
Dynamic variables can be integrated into multiple aspects of your agent:
- System prompts to customize behavior and context
- First messages to personalize greetings
- Tool parameters to pass user-specific data
Here are a few examples where dynamic variables are useful:
- Personalizing greetings with user names
- Including account details in responses
- Passing data to tool calls
- Customizing behavior based on subscription tiers
Dynamic variables are ideal for injecting user-specific data that shouldn’t be hardcoded into your agent’s configuration.
Guide
Prerequisites
- An ElevenLabs account
- A configured ElevenLabs Conversational Agent (create one here)
Define dynamic variables in prompts
Add variables using double curly braces {{variable_name}}
in your:
- System prompts
- First messages
- Tool parameters
Define dynamic variables in tools
You can also define dynamic variables in the tool configuration.
To create a new dynamic variable, set the value type to Dynamic variable and click the +
button.
Pass variables at runtime
When starting a conversation, provide the dynamic variables in your code:
Ensure you have the latest SDK installed.
Supported Types
Dynamic variables support these value types:
Troubleshooting
Variables not replacing
Verify that:
- Variable names match exactly (case-sensitive)
- Variables use double curly braces:
{{ variable_name }}
- Variables are included in your dynamic_variables object
Type errors
Ensure that:
- Variable values match the expected type
- Values are strings, numbers, or booleans only