https://retellai.com/?utm_source=discord&utm_medium=seo logo
I have a little issue with my agent
# ❓・ai-evy-support
a
I have a little issue with my agent. I have set the inbound webhook, so it should reveal the user_number to the agent, however, when the agent asks "do you want to use the number you are calling from for the booking?" and I say yes and then so waht is the number I am calling from, the agent tells me that it doesn't have access to it. Why is that? this has worked before @AI Evy
a
Thanks for tagging me @anton333_50203. I'll look through relevant sources and get back to you shortly.
### Answer The issue you're experiencing could be related to how the inbound webhook is configured and whether the phone number information is being properly passed to your agent through dynamic variables [(1) ]() . According to the inbound webhook documentation, the webhook receives the
from_number
in the payload, which represents the caller's phone number . Here's what the webhook payload looks like:
Copy code
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:
Copy code
json
{
 "call_inbound": {
 "override_agent_id": "agent_12345",
 "override_agent_version": 1,
 "dynamic_variables": {
 "customer_name": "John Doe"
 },
 "metadata": {
 "random_id": "12345"
 }
 }
}
Based on community discussions, there have been reported issues where inbound webhook URLs fail to save properly or get removed when agent configurations are updated [(2) ]() . One user reported that "If I go back to my conversation agent and then save the agent, the webhook on the phone number is lost" . To troubleshoot your issue: 1. Verify that your inbound webhook URL is still properly configured on your phone number 2. Ensure your webhook is returning the caller's phone number as a dynamic variable (e.g.,
caller_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.
​ To learn more, see the sources I considered: [[1] Inbound call webhook](https://docs.retellai.com/features/inbound-call-webhook) [[2] inbound webhook URL failing to save (or stay saved) and wont work together with conversation agaent](https://discord.com/channels/1186424376300679209/1398428473781125314) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
a
well. I set the response webhook to be this: { "call_inbound": { "dynamic_variables": { "user_number": "{{ $json.body.call_inbound.from_number }}" } } } and "{{ $json.body.call_inbound.from_number }}" is the "from_number" that webhook receives
well, I set the response webhook to be this: { "call_inbound": { "dynamic_variables": { "user_number": "{{ $json.body.call_inbound.from_number }}" } } } and "{{ $json.body.call_inbound.from_number }}" is the "from_number" that webhook receives @AI Evy
a
Thanks for the follow-up, @anton333_50203. I'll get back to you soon.
### Answer Your webhook response structure looks correct for setting dynamic variables [(1) ]() . However, there are a few things to check: 1. **Agent Prompt Configuration**: Make sure your agent's prompt references the dynamic variable correctly using
{{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 once
properly set through the inbound webhook response [(1) ]() [(2) ]() .
​ To learn more, see the sources I considered: [[1] Inbound call webhook](https://docs.retellai.com/features/inbound-call-webhook) [[2] Dynamic Variables](https://docs.retellai.com/build/dynamic-variables) [[3] Simulation Testing Now Live for All Agents](https://www.retellai.com/changelog/simulation-testing-now-live-for-all-agents-c27zh) [[4] Inbound call](https://discord.com/channels/1186424376300679209/1342928803902652516) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
a
is there a system variable"user_number"?
is there a system variable"user_number"? @AI Evy
a
Thanks for the follow-up, @anton333_50203. I'll get back to you soon.
### Answer Yes, there is a system variable
{{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 .
​ To learn more, see the sources I considered: [[1] Dynamic Variables](https://docs.retellai.com/build/dynamic-variables) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
a
I just replaced the value to "user_phone_number" and am sending the correct webhook reponse: { "call_inbound": { "dynamic_variables": { "user_phone_number": "{{ $json.body.call_inbound.from_number }}", "from_number": "{{ $json.body.call_inbound.from_number }}" } } } but when asked, the agent still says "sorry, I don't have access to the phone number. What the f?" @AI Evy
a
Thanks for the follow-up, @anton333_50203. I'll get back to you soon.
### Answer Your webhook response structure looks correct, but there are a few things to check: 1. Verify the webhook is actually receiving and processing the data correctly. The
{{ $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) ]() :
Copy code
json
{
  "first_name": "Reece", 
  "phone_number": "+18005551212"
}
Try using the built-in
{{user_number}}
system variable first, as it should automatically contain the caller's phone number without requiring any webhook configuration [(2) ]() .
​ To learn more, see the sources I considered: [[1] Discord message from @fyodor2572 on 2025-01-13](https://discord.com/channels/1186424376300679209/1186462578310910112/1328501089112424508) [[2] Dynamic Variables](https://docs.retellai.com/build/dynamic-variables) [[3] Import Phone Number](https://docs.retellai.com/api-references/import-phone-number) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
a
Help me troubleshoot this! Everything is correct, but the agent refuses to see the number wtf!
Help me troubleshoot this! Everything is correct, but the agent refuses to see the number wtf! @AI Evy
a
Thanks for the follow-up, @anton333_50203. I'll get back to you soon.
### Answer
message has been deleted
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
a
are you stuck @AI Evy
a
Thanks for the follow-up, @anton333_50203. I'll get back to you soon.
### Answer ### Answer Not stuck! Let me help you troubleshoot this dynamic variable issue systematically. Based on the available sources, I can see your phone number can be updated with an inbound webhook URL using this format [(1) ]() :
Copy code
javascript
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 :
Copy code
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?
​ To learn more, see the sources I considered: [[1] Update Phone Number](https://docs.retellai.com/api-references/update-phone-number) [[2] Debug guide](https://docs.retellai.com/build/conversation-flow/debug-guide) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
a
what's the good agent token usage I should aim for? I just created two agents that identifies if the job is within the scope of procided services + answers faqs and collects details to book an appointment and got average token use of 4300. I am utilizing kowledge base and so on but just wondering if it is too much @AI Evy
a
Thanks for the follow-up, @anton333_50203. I'll get back to you soon.
### Answer Based on the available sources, I can see that Retell AI provides token usage information in the call response through the
llm_token_usage
field [(1) ]() . The Get Call API response shows this structure :
Copy code
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?
​ To learn more, see the sources I considered: [[1] Get Call](https://docs.retellai.com/api-references/get-call) [[2] Knowledge Base](https://docs.retellai.com/build/knowledge-base) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
a
sure
What's the reason for this error? "Failed to get LLM response Error: Internal Server Error"
What's the reason for this error? "Failed to get LLM response Error: Internal Server Error" @AI Evy I always get it at a specific point....
a
Thanks for the follow-up, @anton333_50203. I'll get back to you soon.
### Answer Based on the available sources, the "Failed to get LLM response - Error: Internal Server Error" can have several causes: Most Common Causes: 1. **Custom Function Issues**: A common cause is problems with custom functions [(1) ]() . One user reported that after updating their custom function, their agent completely broke with the same error you're seeing . The solution was removing the custom functions, which restored the agent . 2. **TTS Provider Issues**: Internal server errors can occur when the selected voice goes down and the fallback voice also fails [(2) ]() . If there's a TTS provider outage, the system returns a 500 Internal Server Error . 3. **API Key Issues**: Internal Server Error (500) during operations is often caused by API key problems - like using an invalid, expired, or incorrectly permissioned key [(3) ]() . Troubleshooting Steps: Since you mention it happens "at a specific point," this suggests it's likely related to a custom function or specific agent configuration: 1. **Check Custom Functions**: Try removing or simplifying any custom functions in your agent, then test again [(1) ]() . If it works, re-add logic step-by-step to find the breaking change . 2. **Verify API Keys**: Ensure your API keys are valid and have the right permissions [(3) ]() . 3. **Check TTS Configuration**: Verify your voice settings and fallback voice configuration are valid [(2) ]() . 4. **Agent Configuration**: If only one agent is throwi
ng "Internal Server Error" while others work fine, the issue is likely in that agent's config [(1) ]() . The fact that it occurs at a specific point strongly suggests a custom function or configuration issue rather than a general system problem .
​ To learn more, see the sources I considered: [[1] Internal Error - Voice agent completely broken](https://discord.com/channels/1186424376300679209/1404391587173236896) [[2] [500] internal server error: error from voice backend: {\"status\":\"error\",\"message\":\"Internal](https://discord.com/channels/1186424376300679209/1395437135443792133) [[3] Getting internal server error when trying to create voice based test simulation](https://discord.com/channels/1186424376300679209/1382361188440215812) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
a
@AI Evy But how can I debug it if it doesn't even show me anything other than that message? @AI Evy
a
Thanks for the follow-up, @anton333_50203. I'll get back to you soon.
### Answer Based on the available sources, debugging "Internal Server Error" messages can be challenging when they don't provide detailed error information [(1) ]() . Here are the debugging approaches available: Available Debugging Options: 1. **Custom Function Verification**: If you have custom functions, you can verify the request is from Retell using the signature verification [(2) ]() [(3) ]() :
Copy code
python
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"}
        )
[(3) ]() 2. **Call Information**: After the call ends, you can access detailed logs through the call object which includes
public_log_url
for debugging and tracing [(4) ]() :
Copy code
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.
​ To learn more, see the sources I considered: [[1] Internal Error - Voice agent completely broken](https://discord.com/channels/1186424376300679209/1404391587173236896) [[2] Custom Function](https://docs.retellai.com/build/conversation-flow/custom-function) [[3] Integrate any system with custom function](https://docs.retellai.com/build/single-multi-prompt/custom-function) [[4] Update Call](https://docs.retellai.com/api-references/update-call) [[5] [500] internal server error: error from voice backend: {\"status\":\"error\",\"message\":\"Internal](https://discord.com/channels/1186424376300679209/1395437135443792133) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
a
But it's super strange because I see this error when the agent is simply asking me for my name... @AI Evy No functions or anything like that are involved... maybe only dynamic variable
a
Thanks for the follow-up, @anton333_50203. I'll get back to you soon.
### Answer Based on the available sources, if the error occurs during basic conversation (like asking for your name) without custom functions, the dynamic variable configuration could indeed be the culprit [(1) ]() . Dynamic Variable Related Issues: Since you mentioned dynamic variables, the issue might be related to how they're being processed [(2) ]() . Dynamic variables can be used in various parts of the agent including the prompt, begin message, and tool descriptions . If there's a malformed dynamic variable reference in your agent's prompt or configuration, it could cause the LLM to fail when processing the request. Troubleshooting Steps: 1. **Check Agent Prompt**: Review your agent's prompt for any dynamic variable references like
{{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 function
s in their case) and then re-adding them step by step to identify the breaking change. Since your error occurs at such a basic interaction point, I'd recommend temporarily removing all dynamic variable references from your agent configuration to isolate whether that's the cause.
​ To learn more, see the sources I considered: [[1] Internal Error - Voice agent completely broken](https://discord.com/channels/1186424376300679209/1404391587173236896) [[2] Dynamic Variables](https://docs.retellai.com/build/dynamic-variables) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
a
Are you joking... It would take hours to remove and then add them back in. This is ridiculous! @AI Evy
a
Thanks for the follow-up, @anton333_50203. I'll get back to you soon.
### Answer I understand your frustration. Based on the available sources, there are a few more targeted approaches you can try before doing a complete rebuild: Quick Checks First: 1. **Dynamic Variable Syntax**: Make sure there are no spaces in your dynamic variable references [(1) ]() . One user had their agent working after fixing
{{ provider_info} }
to
{{provider_info}}
. 2. **Webhook Format**: Double-check your inbound webhook response format. It should be [(2) ]() :
Copy code
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?
​ To learn more, see the sources I considered: [[1] Issue with Dynamic Variables.](https://discord.com/channels/1186424376300679209/1336469878068219904) [[2] Agent not picking up dynamic variables](https://discord.com/channels/1186424376300679209/1395530229640073329) [[3] Dynamic Variables](https://docs.retellai.com/build/dynamic-variables) [[4] List Calls](https://docs.retellai.com/api-references/list-calls) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.