superGamer69
12/16/2025, 5:25 PMAI Evy
12/16/2025, 5:25 PMAI Evy
12/16/2025, 5:26 PMretell_llm_dynamic_variables field in your API call, the agent doesn't automatically "know" about them unless you reference them in your prompt using the {{variable_name}} syntax. [(1) ]()
To make your dynamic variables accessible to the agent:
1. Add the variable placeholders in your agent's prompt. For example:
"Hello {{customer_name}}, I understand you're interested in {{product_name}}. How can I help you today?"
2. Pass the variables when creating the call: [(2) ]()
javascript
const phoneCallResponse = await client.call.createPhoneCall({
from_number: '+14157774444',
to_number: '+12137774445',
}) ;
With the retell_llm_dynamic_variables field containing:
json
{ "customer_name": "John Doe" }
Additional considerations:
- If a dynamic variable has no assigned value, it remains in its raw form with curly braces intact (e.g., {{user_name}} will appear literally if not provided) . [(1) ]()
- If you're using a Conversation Flow with a Logic Split node at the very start, the variables may not be "hydrated" (fully loaded) yet—consider adding a brief initialization step or using prompt-based logic instead. [(8) ]()AI Evy
12/16/2025, 5:26 PMAI Evy
12/16/2025, 5:26 PMsuperGamer69
12/16/2025, 5:27 PMAI Evy
12/16/2025, 5:27 PMAI Evy
12/16/2025, 5:28 PMretell_llm_dynamic_variables as key-value pairs (all values must be strings) :
[(1) ]() , [(2) ]()
json
{
"user_name": "John Smith",
"email": "john@example.com",
"phone": "555-1234",
"product_interest": "Premium Plan",
"form_submission_date": "December 15, 2025"
}
[(1) ]()
2. Reference each variable in your agent's prompt using {{variable_name}} syntax:
You are helping a user who submitted a form. Here are their details:
- Name: {{user_name}}
- Email: {{email}}
- Phone: {{phone}}
- Product Interest: {{product_interest}}
- Submission Date: {{form_submission_date}}
Use this information to assist the caller. When they ask about their form details, reference the above variables.
Key points:
- All values in retell_llm_dynamic_variables must be strings—numbers, booleans, or other data types are not supported.
- The agent will only "know" about variables that are explicitly referenced in the prompt.
- If a variable isn't provided, it will appear with curly braces intact (e.g., {{email}}) .
If variables still aren't being picked up, one community member resolved a similar issue by returning variables via the inbound call webhook format instead:
[(3) ]()
json
{
"call_inbound": {
"dynamic_variables": {
"user_name": "John Smith",
"email": "john@example.com"
}
}
}AI Evy
12/16/2025, 5:28 PMAI Evy
12/16/2025, 5:28 PMsuperGamer69
12/16/2025, 5:31 PMAI Evy
12/16/2025, 5:31 PMAI Evy
12/16/2025, 5:31 PMPOST request to your webhook URL with a payload containing from_number, to_number, and optionally agent_id and agent_version.
- You respond with JSON to set dynamic variables, override the agent, or reject the call.
Sample request payload:
json
{
"event": "call_inbound",
"call_inbound": {
"agent_id": "agent_12345",
"agent_version": 1,
"from_number": "+12137771234",
"to_number": "+12137771235"
}
}
Sample response (to inject dynamic variables) :
json
{
"call_inbound": {
"dynamic_variables": {
"user_name": "John Smith",
"email": "john@example.com"
}
}
}
This is useful when you want to pass form details or user-specific data into the call before it connects—exactly what you were trying to do with dynamic variables. [(2) ]()
You can set the inbound_webhook_url on your phone number via the dashboard or API. [(3) ]()AI Evy
12/16/2025, 5:31 PMAI Evy
12/16/2025, 5:31 PMsuperGamer69
12/16/2025, 5:33 PMAI Evy
12/16/2025, 5:33 PMAI Evy
12/16/2025, 5:33 PMretell_llm_dynamic_variables field in your request body:
javascript
import Retell from 'retell-sdk';
const client = new Retell({
apiKey: 'YOUR_RETELL_API_KEY',
}) ;
const phoneCallResponse = await client.call.registerPhoneCall({
agent_id: 'oBeDLoLOeuAbiuaMFXRtDOLriTJ5tSxD',
}) ;
console.log(phoneCallResponse.agent_id) ;
With retell_llm_dynamic_variables structured as:
json
{ "customer_name": "John Doe" }
Important reminders:
1. Reference variables in your prompt using {{variable_name}} syntax—the agent won't automatically "know" about them otherwise. [(2) ]()
2. All values must be strings.
3. If a variable isn't provided, it remains in raw form (e.g., {{customer_name}}) .
If variables still aren't being picked up, one community member resolved a similar issue by returning variables via the webhook response format: [(3) ]()
json
{
"call_inbound": {
"dynamic_variables": {
"caller_name": " "
}
}
}
Make sure your prompt explicitly references each variable you want the agent to use.AI Evy
12/16/2025, 5:33 PMAI Evy
12/16/2025, 5:33 PMsuperGamer69
12/16/2025, 5:34 PMAI Evy
12/16/2025, 5:34 PMAI Evy
12/16/2025, 5:34 PMretell_llm_dynamic_variables. [(2) ]()
To avoid conflicts:
1. Use different variable names for variables you inject via API vs. variables you extract mid-call. For example:
- API-injected: {{user_name_api}}
- Extracted: {{user_name_extracted}}
2. Check your Extract Dynamic Variable tool configuration — ensure the variable names defined there don't match the ones you're passing in. [(1) ]()
How the Extract Dynamic Variables tool works:
- You define variables with a Variable Name, Description, and Variable Type (Text, Number, Enum, or Boolean) .
- When the LLM calls this tool, it extracts values from the conversation and saves them under those variable names.
- These extracted variables can then be referenced using {{variable_name}} syntax. [(2) ]()
If you need both injected and extracted data, keep the naming distinct so they don't collide.AI Evy
12/16/2025, 5:34 PMAI Evy
12/16/2025, 5:34 PMsuperGamer69
12/16/2025, 5:36 PMAI Evy
12/16/2025, 5:36 PMAI Evy
12/16/2025, 5:36 PMWhen user states his name and phone number, please extract the information by calling the `extract_user_details` function.
2. Batch your extractions. Rather than extracting after every piece of information, instruct the agent to collect multiple data points first, then call the tool once. For example:
After the user has provided their name, email, and phone number, call the extract_user_details function to save all three values at once.
3. Limit the tool's scope. Only define variables you actually need to extract—each variable adds processing overhead.
The key is controlling when the LLM decides to invoke the tool through explicit prompt instructions rather than letting it call on every utterance.AI Evy
12/16/2025, 5:36 PMAI Evy
12/16/2025, 5:36 PM