anton333_50203
08/21/2025, 1:49 PMAI Evy
08/21/2025, 1:49 PMAI Evy
08/21/2025, 1:49 PMfrom_number in the payload, which represents the caller's phone number . Here's what the webhook payload looks like:
json
{
"event": "call_inbound",
"call_inbound": {
"agent_id": "agent_12345",
"from_number": "+12137771234",
"to_number": "+12137771235"
}
}
To make this information available to your agent, you need to return it in the webhook response using dynamic variables . The response should look like this:
json
{
"call_inbound": {
"override_agent_id": "agent_12345",
"override_agent_version": 1,
"dynamic_variables": {
"customer_name": "John Doe"
},
"metadata": {
"random_id": "12345"
}
}
}AI Evy
08/21/2025, 1:49 PMcaller_phone_number) in the response
3. Make sure your agent prompt references the correct dynamic variable name to access the caller's number
If the webhook configuration keeps getting lost or the dynamic variables aren't being set properly, this could explain why your agent doesn't have access to the caller's phone number information.AI Evy
08/21/2025, 1:49 PMAI Evy
08/21/2025, 1:49 PManton333_50203
08/21/2025, 1:51 PManton333_50203
08/21/2025, 1:51 PMAI Evy
08/21/2025, 1:51 PMAI Evy
08/21/2025, 1:52 PM{{user_number}} [(2) ]() . For example, in your prompt you should have something like "The caller's phone number is {{user_number}}" so the agent can access this information .
2. **System Default Variables**: Retell AI also provides system default dynamic variables for phone calls, including {{user_number}} which represents the user's phone number (from_number for inbound, to_number for outbound) [(2) ]() [(3) ]() . This might conflict with your custom variable name.
3. **Variable Processing**: The {{ $json.body.call_inbound.from_number }} syntax appears to be from your webhook processing tool (like Make.com) , which should resolve to the actual phone number before being sent to Retell AI [(4) ]() .
To troubleshoot:
- Try using a different variable name like caller_phone instead of user_number to avoid potential conflicts with system variables [(2) ]()
- Verify that your webhook is actually returning the resolved phone number (not the template syntax) in the response to Retell AI [(1) ]()
- Check that your agent's prompt explicitly references the dynamic variable you're setting [(2) ]()
The dynamic variable should be available throughout the call onceAI Evy
08/21/2025, 1:52 PMAI Evy
08/21/2025, 1:52 PManton333_50203
08/21/2025, 1:53 PManton333_50203
08/21/2025, 1:54 PMAI Evy
08/21/2025, 1:54 PMAI Evy
08/21/2025, 1:54 PM{{user_number}} in Retell AI [(1) ]() . According to the documentation, {{user_number}} is a system-provided dynamic variable that represents the user's phone number . Specifically, it contains the from_number for inbound calls and the to_number for outbound calls .
This variable is only available for phone calls and will automatically contain the caller's phone number without you needing to set it manually through your webhook .
Since you're using user_number as your custom dynamic variable name in your webhook response, this could potentially create a conflict with the system variable of the same name. You might want to consider using a different variable name like caller_phone or custom_user_number to avoid any potential conflicts with the built-in system variable .AI Evy
08/21/2025, 1:54 PMAI Evy
08/21/2025, 1:54 PManton333_50203
08/21/2025, 2:11 PMAI Evy
08/21/2025, 2:11 PMAI Evy
08/21/2025, 2:13 PM{{ $json.body.call_inbound.from_number }} syntax suggests you're using Make.com or a similar platform - ensure this is resolving to the actual phone number value, not the template string [(1) ]() .
2. Check your agent's prompt configuration. You need to explicitly reference the dynamic variables in your agent's prompt for the agent to know they exist [(2) ]() . For example, include something like: "The caller's phone number is {{user_phone_number}}" in your prompt .
3. Use the system variable instead. Since there's already a built-in {{user_number}} system variable that automatically contains the user's phone number (from_number for inbound calls) , you might not need the custom webhook at all . The system variable should be available by default for phone calls .
4. Test with the inbound webhook URL configuration. Make sure your inbound webhook URL is properly set on your phone number configuration [(3) ]() . You can set this via the API when importing a phone number using the inbound_webhook_url parameter .
The inbound call webhook expects a JSON response with dynamic variables in this format [(1) ]() :
json
{
"first_name": "Reece",
"phone_number": "+18005551212"
}AI Evy
08/21/2025, 2:13 PMAI Evy
08/21/2025, 2:13 PManton333_50203
08/21/2025, 2:18 PManton333_50203
08/21/2025, 2:18 PMAI Evy
08/21/2025, 2:18 PMAI Evy
08/21/2025, 2:23 PMAI Evy
08/21/2025, 2:23 PMAI Evy
08/21/2025, 2:24 PManton333_50203
08/21/2025, 2:24 PMAI Evy
08/21/2025, 2:24 PMAI Evy
08/21/2025, 2:24 PMjavascript
const phoneNumberResponse = await client.phoneNumber.update('+14157774444', {
inbound_agent_id: 'oBeDLoLOeuAbiuaMFXRtDOLriTJ5tSxD',
nickname: 'Frontdesk Number',
outbound_agent_id: 'oBeDLoLOeuAbiuaMFXRtDOLriTJ5tSxD',
}) ;
The phone number response shows the inbound_webhook_url field :
json
{
"phone_number": "+14157774444",
"phone_number_type": "retell-twilio",
"phone_number_pretty": "+1 (415) 777-4444",
"inbound_agent_id": "oBeDLoLOeuAbiuaMFXRtDOLriTJ5tSxD",
"outbound_agent_id": "oBeDLoLOeuAbiuaMFXRtDOLriTJ5tSxD",
"inbound_agent_version": 1,
"outbound_agent_version": 1,
"area_code": 415,
"nickname": "Frontdesk Number",
"inbound_webhook_url": "<https://example.com/inbound-webhook%22,>
"last_modification_timestamp": 1703413636133
}
However, the specific troubleshooting steps for dynamic variable issues with inbound webhooks aren't detailed in the available sources. The sources also mention debugging approaches for conversation flow agents [(2) ]() , but don't specifically address webhook dynamic variable troubleshooting.
For this specific technical issue where your webhook response format appears correct but the agent still can't access the phone number variable, I'd recommend:
- Visit [Contact Sales]()
- Visit [)
Would you like a general answer based on my knowledge about common webhook and dynamic variable troubleshooting instead?AI Evy
08/21/2025, 2:24 PMAI Evy
08/21/2025, 2:25 PManton333_50203
08/21/2025, 5:19 PMAI Evy
08/21/2025, 5:19 PMAI Evy
08/21/2025, 5:20 PMllm_token_usage field [(1) ]() . The Get Call API response shows this structure :
json
"llm_token_usage": {
"values": [
123
],
"average": 123,
"num_requests": 123
}
However, the sources don't provide specific benchmarks or recommendations for what constitutes "good" token usage for agents with knowledge base integration [(2) ]() . The knowledge base feature does add some overhead since it retrieves relevant information during calls and feeds it to the LLM as context .
Your 4300 average token usage for agents that handle service scope identification, FAQ responses, and appointment booking with knowledge base integration isn't directly addressed in the available documentation. The sources mention that knowledge base usage is billed at $0.005 per minute of calls that have knowledge base enabled, regardless of whether you're using one or multiple knowledge bases .
For specific guidance on optimal token usage benchmarks for your use case, I'd recommend:
- Visit [Contact Sales]()
- Visit [)
Would you like a general answer based on my knowledge about token optimization strategies instead?AI Evy
08/21/2025, 5:20 PMAI Evy
08/21/2025, 5:20 PManton333_50203
08/21/2025, 5:20 PManton333_50203
08/21/2025, 9:18 PManton333_50203
08/21/2025, 9:19 PMAI Evy
08/21/2025, 9:19 PMAI Evy
08/21/2025, 9:19 PMAI Evy
08/21/2025, 9:19 PMAI Evy
08/21/2025, 9:19 PManton333_50203
08/21/2025, 9:20 PMAI Evy
08/21/2025, 9:20 PMAI Evy
08/21/2025, 9:21 PMpython
from fastapi import FastAPI, Request
from fastapi.responses import JSONResponse
from retell import Retell
retell = Retell(api_key=os.environ["RETELL_API_KEY"])
@app.post("/check-weather")
async def check-weather(request: Request) :
try:
post_data = await request.json()
valid_signature = retell.verify(
json.dumps(post_data, separators=(",", ":") , ensure_ascii=False) ,
api_key=str(os.environ["RETELL_API_KEY"]) ,
signature=str(request.headers.get("X-Retell-Signature") ) ,
)
if not valid_signature:
print(
"Received Unauthorized",
post_data["event"],
post_data["data"]["call_id"],
)
return JSONResponse(status_code=401, content={"message": "Unauthorized"})
args = post_data["args"]
if args["city"] == "New York":
return JSONResponse(status_code=200, content={"result": "25f and sunny"})
else:
return JSONResponse(status_code=200, content={"result": "20f and cloudy"})
except Exception as err:
print(f"Error in webhook: {err}")
return JSONResponse(
status_code=500, content={"message": "Internal Server Error"}
)AI Evy
08/21/2025, 9:21 PMpublic_log_url for debugging and tracing [(4) ]() :
javascript
const callResponse = await client.call.update('call_a4441234567890777c4a4a123e6', {
metadata: { customer_id: 'cust_123', notes: 'Follow-up required' },
opt_out_sensitive_data_storage: true,
}) ;
Systematic Debugging Approach:
Based on community experience, the most effective debugging method is elimination [(1) ]() :
- Remove custom functions one by one to isolate the issue
- Test with minimal agent configuration
- Re-add components step-by-step to identify the breaking change
Unfortunately, Retell AI doesn't provide real-time detailed error logs during the call for Internal Server Errors [(5) ]() [(1) ]() . The sources indicate that users have requested better error messaging for provider issues [(5) ]() , but currently the system returns generic 500 errors without specific details.AI Evy
08/21/2025, 9:21 PMAI Evy
08/21/2025, 9:21 PManton333_50203
08/21/2025, 9:23 PMAI Evy
08/21/2025, 9:23 PMAI Evy
08/21/2025, 9:23 PM{{user_phone_number}} or {{from_number}} . If these variables aren't being properly resolved, it could cause the LLM to error out.
2. **Test Without Dynamic Variables**: Try temporarily removing all dynamic variable references from your agent's prompt and configuration to see if the error persists [(1) ]() .
3. **Verify Webhook Response**: Since you're using an inbound webhook, ensure the webhook is returning properly formatted dynamic variables [(2) ]() . The webhook response should contain actual values, not template syntax like {{ $json.body.call_inbound.from_number }}.
Similar Case from Community:
One user experienced similar issues where their agent was completely broken with "Internal Server Error" [(1) ]() . In that case, the problem was resolved by systematically removing components (custom functionAI Evy
08/21/2025, 9:23 PMAI Evy
08/21/2025, 9:23 PMAI Evy
08/21/2025, 9:23 PManton333_50203
08/21/2025, 9:26 PMAI Evy
08/21/2025, 9:26 PMAI Evy
08/21/2025, 9:26 PM{{ provider_info} } to {{provider_info}} .
2. **Webhook Format**: Double-check your inbound webhook response format. It should be [(2) ]() :
json
{
"call_inbound": {
"dynamic_variables": {
"business_name": "Brian's Electrical"
}
}
}
3. **Use System Variables**: Since you're trying to access the user's phone number, try using the built-in {{user_number}} system variable instead [(3) ]() . This automatically contains the user's phone number (from_number for inbound calls) without requiring webhook configuration .
Alternative Debugging:
Check your call logs after the error occurs. The List Calls API provides detailed information including public_log_url for debugging and tracing [(4) ]() . This might give you more specific error details than what you're seeing during the call.
If the basic troubleshooting doesn't work, you can:
- Visit [Contact Sales]()
- Visit [)
Would you like a general answer based on my knowledge about common dynamic variable troubleshooting instead?AI Evy
08/21/2025, 9:26 PMAI Evy
08/21/2025, 9:26 PM