kartik
12/16/2025, 5:40 PMAI Evy
12/16/2025, 5:40 PMAI Evy
12/16/2025, 5:40 PM{{transfer_target}})
3. Configure the Call Transfer Node to use that dynamic variable as the transfer destination
In the Call Transfer Node, you can set the transfer number to a dynamic variable that gets substituted at runtime.
Key points:
- The phone number should be in E.164 format (e.g., +12137771234)
- Dynamic variables work in tool configurations including custom function URLs and tool descriptions [(2) ]()
- You can update the dynamic variable during the call flow before triggering the transfer [(3) ]()
So your flow would be:
1. Call your n8n custom function to retrieve the phone number
2. Store the returned number in a dynamic variable
3. The Call Transfer Node uses {{transfer_target}} (or whatever you name it) as the destination
This allows the transfer number to be different for every call based on your n8n logic.
---AI Evy
12/16/2025, 5:40 PMAI Evy
12/16/2025, 5:40 PMkartik
12/16/2025, 5:42 PMkartik
12/16/2025, 5:43 PMAI Evy
12/16/2025, 5:43 PMAI Evy
12/16/2025, 5:44 PMjson
{
"retell_llm_dynamic_variables": {
"transfer_target": "+12137771234"
}
}
[(2) ]()
For inbound calls (webhook response) :
json
{
"call_inbound": {
"dynamic_variables": {
"transfer_target": "+12137771234"
}
}
}
[(1) ]()
Once you share your workflow, I can confirm if the structure is correct for your use case.AI Evy
12/16/2025, 5:44 PMAI Evy
12/16/2025, 5:44 PMkartik
12/16/2025, 5:45 PMkartik
12/16/2025, 5:47 PMAI Evy
12/16/2025, 5:47 PMAI Evy
12/16/2025, 5:47 PMjson
{
"call_inbound": {
"dynamic_variables": {
"transfer_target": "+12137771234"
}
}
}
The override_agent_id field is only needed if you want to change which agent handles the call. If you already have an inbound agent set on the phone number and just want to pass dynamic variables, you can omit it entirely.
Optional fields you can include:
- override_agent_id – only if you want to switch agents
- override_agent_version – only if you want a specific agent version
- dynamic_variables – your custom variables
- metadata – additional call metadata
- agent_override – to override specific agent settings
So your n8n "Respond to Webhook" node just needs to return the call_inbound.dynamic_variables object with your phone number variable.
---AI Evy
12/16/2025, 5:47 PMAI Evy
12/16/2025, 5:47 PMkartik
12/16/2025, 6:30 PMAI Evy
12/16/2025, 6:30 PMAI Evy
12/16/2025, 6:30 PMcall_inbound structure is specifically for the inbound webhook response when a call first comes in—not for mid-call custom function responses. [(1) ]()
For a custom function called mid-call, the response format should be different. Custom functions return data that the LLM can use, but to update dynamic variables mid-call, you need to return the value directly so it can be stored.
The problem:
Your function returns:
json
{"call_inbound":{"dynamic_variables":{"agent_phone":"+917508966856"}}}
This nested structure isn't being parsed correctly to populate the {{agent_phone}} variable for the transfer node.
Suggested approach:
1. Have your custom function return the phone number directly:
json
{
"agent_phone": "+917508966856"
}
2. In your conversation flow, after calling the custom function, you need to extract and store that returned value into a dynamic variable before the transfer node uses it.
3. Make sure the transfer node is configured to use {{agent_phone}} and that this variable is properly set before the transfer is triggered.
The error "Transfer destination number is a dynamic variable that's not populated" confirms that {{agent_phone}} isn't being recognized as set at the time of transfer. [(2) ]()
Check out these potentially useful sources for more details on dynamic variable handling:
- [Dynamic Variables]()
Would you like a general answer on mid-call variable updates, or can you share how your conversation flow stores the function result?AI Evy
12/16/2025, 6:30 PMAI Evy
12/16/2025, 6:30 PMkartik
12/16/2025, 6:36 PMkartik
12/16/2025, 6:36 PMAI Evy
12/16/2025, 6:36 PMAI Evy
12/16/2025, 6:37 PMcall_inbound structure you're using is specifically for inbound webhook responses when a call first arrives—not for mid-call custom function responses. [(1) ]()
For a custom function that returns data mid-call, you should simplify your JSON schema to return the phone number directly:
json
{
"type": "object",
"properties": {
"agent_phone": {
"type": "string",
"description": "Phone number to transfer the call to"
}
},
"required": [
"agent_phone"
]
}
And your n8n webhook should return:
json
{
"agent_phone": "+917508966856"
}
The call_inbound.dynamic_variables format is used when responding to the inbound webhook (set via inbound_webhook_url on the phone number) to inject variables at call start. , [(2) ]() , [(3) ]()
For outbound calls, dynamic variables are passed via retell_llm_dynamic_variables in the API request. [(4) ]() , [(5) ]()
Mid-call custom functions should return the data directly so your conversation flow can use it.AI Evy
12/16/2025, 6:37 PMAI Evy
12/16/2025, 6:37 PMkartik
12/16/2025, 6:43 PMAI Evy
12/16/2025, 6:43 PMAI Evy
12/16/2025, 6:43 PMjson
[{"agent_phone":"+917508966856"},{"agent_phone":"+917508966856"},{"agent_phone":"+917508966856"},{"agent_phone":"+917508966856"}]
Custom function responses are converted to string before being processed, and this array format isn't being properly extracted into your dynamic variable. [(1) ]()
Fix your n8n workflow to return a single object:
json
{"agent_phone":"+917508966856"}
Additionally, make sure you're using the response variables feature in your custom function to extract the value. You need to configure "Set response variables" to extract agent_phone from the response and save it as a dynamic variable.
Also, based on a similar issue, ensure the dynamic variable is referenced in the description of your custom function parameters using the {{variable_name}} syntax (e.g., {{agent_phone}}) . [(2) ]()
Steps to verify:
1. Update n8n to return a single object, not an array
2. In your custom function node, configure response variables to extract agent_phone and store it
3. Ensure the transfer node uses {{agent_phone}} as the destination [(3) ]()AI Evy
12/16/2025, 6:43 PMAI Evy
12/16/2025, 6:43 PMkartik
12/16/2025, 6:45 PMAI Evy
12/16/2025, 6:45 PMAI Evy
12/16/2025, 6:45 PMjson
[{"agent_phone":"+917508966856"},{"agent_phone":"+917508966856"},...]
This is an array. Custom function responses are converted to string before sending to the LLM for processing, and an array format won't properly populate your dynamic variable. [(1) ]()
In your n8n workflow, modify your response node to return a **single object**:
json
{"agent_phone":"+917508966856"}
If you're getting multiple results from a previous node, use an n8n "Item Lists" or "Code" node to select just the first item before returning it.
---
### Step 2: Configure response variables to extract and store the value
In your custom function configuration, use the "Set response variables" feature to extract the phone number from the API response and save it as a dynamic variable. [(2) ]() , [(1) ]()
For example, if your response body is:
json
{
"agent_phone": "+917508966856"
}AI Evy
12/16/2025, 6:45 PMagent_phone from the response to a dynamic variable (e.g., {{agent_phone}}) . This allows you to reference it later using {{agent_phone}}. [(2) ]() , [(1) ]()
---
### Step 3: Use the dynamic variable in the transfer node
Dynamic variables can be used in transfer call phone numbers. [(3) ]()
In your Call Transfer Node, set the transfer destination to {{agent_phone}}. This placeholder will be substituted at runtime with the value extracted from your custom function response.
Make sure:
- The custom function that fetches the phone number runs before the transfer node in your conversation flow
- The phone number is in proper format (e.g., +917508966856)
- The variable name matches exactly between your response variable configuration and the transfer node
---AI Evy
12/16/2025, 6:45 PMAI Evy
12/16/2025, 6:45 PMAI Evy
12/16/2025, 6:51 PMkartik
12/16/2025, 6:51 PMAI Evy
12/16/2025, 6:51 PMjson
{
"type": "object",
"properties": {
"agent_phone": {
"type": "string",
"description": "Phone number to transfer the call to"
}
},
"required": [
"agent_phone"
]
}
The schema you shared includes many unrelated fields (pets, parking, amenities, city, etc.) which are useful for collecting lead information but won't help extract a transfer phone number.
Key points:
- Custom function parameters define what the LLM sends to your endpoint
- If you only need to fetch a phone number, keep the schema minimal
- Your n8n endpoint should return a single object like {"agent_phone": "+917508966856"}
- Then configure response variables to extract agent_phone and store it as a dynamic variable for use in the transfer node [(2) ]()
If you're using this function for both lead capture and phone extraction, you may want to split them into two separate functions for clarity.AI Evy
12/16/2025, 6:51 PMAI Evy
12/16/2025, 6:51 PMkartik
12/16/2025, 6:51 PMAI Evy
12/16/2025, 6:51 PMkartik
12/16/2025, 6:52 PMAI Evy
12/16/2025, 6:52 PMAI Evy
12/16/2025, 6:52 PMjson
{
"type": "object",
"properties": {
"agent_phone": {
"type": "string",
"description": "Phone number to transfer the call to"
}
},
"required": [
"agent_phone"
]
}
[(1) ]()
And your n8n should return a single object (not an array) :
json
{
"agent_phone": "+917508966856"
}
Then use response variables in your custom function to extract agent_phone from the response and store it as a dynamic variable for use in the transfer node. , [(2) ]()
Please re-share what you meant to show and I can review it.AI Evy
12/16/2025, 6:52 PMAI Evy
12/16/2025, 6:52 PMAI Evy
12/16/2025, 6:52 PMjson
{
"type": "object",
"properties": {
"agent_phone": {
"type": "string",
"description": "Phone number to transfer the call to"
}
},
"required": [
"agent_phone"
]
}
This follows the proper JSON schema format for custom function parameters. , [(2) ]()
Next steps to complete your setup:
1. Make sure your n8n webhook returns a single object (not an array) :
json
{"agent_phone": "+917508966856"}
[(1) ]()
2. Configure response variables in your custom function to extract agent_phone from the response and save it as a dynamic variable for later use. , [(2) ]()
3. In your Call Transfer Node, use {{agent_phone}} as the transfer destination.
The schema defines what the LLM sends to your endpoint, and the response variables feature extracts data from what your endpoint returns. [(1) ]() , [(2) ]()AI Evy
12/16/2025, 6:52 PMAI Evy
12/16/2025, 6:52 PMkartik
12/16/2025, 6:53 PMkartik
12/16/2025, 6:54 PMAI Evy
12/16/2025, 6:54 PMAI Evy
12/16/2025, 6:54 PM{{variable_name}} syntax. [(1) ]()
Try updating your custom function parameter description to include the variable reference:
json
{
"type": "object",
"properties": {
"agent_phone": {
"type": "string",
"description": "Use this as the agent phone: {{agent_phone}}"
}
},
"required": [
"agent_phone"
]
}
Additionally, ensure you have configured "Set response variables" in your custom function node to extract agent_phone from the response and save it as a dynamic variable. The response from your endpoint needs to be explicitly mapped to a variable that persists for use in subsequent nodes.
Key checklist:
1. In your custom function, configure response variables to extract agent_phone and store it
2. Include {{agent_phone}} in the description field of your function parameters
3. Verify the variable is extracted by checking the call history data tab [(2) ]()
4. Ensure the transfer node runs after the extraction function completes and the variable is storedAI Evy
12/16/2025, 6:54 PMAI Evy
12/16/2025, 6:54 PMkartik
12/16/2025, 6:56 PMAI Evy
12/16/2025, 6:56 PMAI Evy
12/16/2025, 6:56 PM{{agent_phone}} set in your transfer function and your extraction function is returning {"agent_phone":"+917508966856"}, the issue is likely that the variable isn't being saved/extracted from the response before the transfer executes.
Based on a similar reported issue, you need to include the dynamic variable reference {{agent_phone}} in the description field of your custom function parameters. [(1) ]()
Update your extraction function description like this:
json
{
"type": "object",
"properties": {
"agent_phone": {
"type": "string",
"description": "Use this as the agent phone: {{agent_phone}}"
}
},
"required": [
"agent_phone"
]
}
Additionally:
- Make sure you have configured "Set response variables" in your custom function node to explicitly extract agent_phone from the response and store it as a dynamic variable [(2) ]()
- Verify in your call history logs that the variable is actually being extracted after the function runs [(1) ]()
- Ensure the extraction function completes before the transfer node triggers
The error "Transfer destination number is a dynamic variable that's not populated" confirms {{agent_phone}} isn't recognized as set at transfer time—even though your function returns the value, it may not be properly mapped to a stored dynamic variable.
---AI Evy
12/16/2025, 6:56 PMAI Evy
12/16/2025, 6:56 PM