Client Nexus
12/29/2025, 10:14 PMAI Evy
12/29/2025, 10:14 PMAI Evy
12/29/2025, 10:14 PMAI Evy
12/29/2025, 10:14 PMAI Evy
12/29/2025, 10:14 PMPOST with payload like:
json
{
"event": "call_inbound",
"call_inbound": {
"agent_id": "agent_12345",
"from_number": "+12137771234",
"to_number": "+12137771235"
}
}
Your server responds with options like override_agent_id, dynamic_variables, or metadata.
*3. Custom Telephony (SIP Trunking) *
If using your own telephony provider, you'll need to register the call via the API using `registerPhoneCall`: [(2) ]()
javascript
import Retell from 'retell-sdk';
const client = new Retell({
apiKey: 'YOUR_RETELL_API_KEY',
}) ;
const phoneCallResponse = await client.call.registerPhoneCall({
agent_id: 'oBeDLoLOeuAbiuaMFXRtDOLriTJ5tSxD',
}) ;
Go ahead and share your questions—happy to help with specifics!Client Nexus
12/30/2025, 10:40 AMAI Evy
12/30/2025, 10:40 AMAI Evy
12/30/2025, 10:40 AMoverride_agent_id based on your own time-of-day logic.
2. Business hours routing
You define your business hours in your own system and configure routing rules in your webhook handler. [(2) ]()
The inbound webhook lets you return different override_agent_id values (Agent A vs Agent B) based on the current time. [(1) ]()
3. Webhook endpoint and campaign context
When an inbound call arrives, Retell `POST`s to the inbound webhook URL configured on your phone number.
The payload includes:
json
{
"event": "call_inbound",
"call_inbound": {
"agent_id": "agent_12345",
"from_number": "+12137771234",
"to_number": "+12137771235"
}
}
You can pass campaign context by returning metadata in your webhook response—this is stored with the call for your tracking purposes.
4. Dynamically changing which agent handles a number
Yes. Your webhook response can include override_agent_id to route to any agent dynamically per-call, without changing the phone number's default inbound agent.
5. Injecting contact data via dynamic variables
Yes. Before the call connects, your webhook can look up the caller by from_number, then return dynamic_variables in your response to inject contact data (e.g., {{customer_name}}) into the agent's prompt.
Example webhook response:AI Evy
12/30/2025, 10:40 AMjson
{
"call_inbound": {
"override_agent_id": "agent_after_hours",
"dynamic_variables": {
"customer_name": "John Doe"
},
"metadata": {
"campaign_id": "camp_123"
}
}
}AI Evy
12/30/2025, 10:40 AMAI Evy
12/30/2025, 10:40 AMClient Nexus
12/30/2025, 10:41 AMAI Evy
12/30/2025, 10:41 AMAI Evy
12/30/2025, 10:41 AMfrom_number and to_number, and you return override_agent_id based on current time.
Option (c) —updating the phone number's inbound_agent_id dynamically via API—would work but adds latency and complexity compared to simply returning override_agent_id per call.
[(2) ]()
---
### CALLER CONTEXT
Pass dynamic data via the inbound webhook response using dynamic_variables.
[(1) ]()
When your webhook receives the inbound call payload, look up the caller by from_number in your DB, then return:
json
{
"call_inbound": {
"override_agent_id": "agent_12345",
"dynamic_variables": {
"customer_name": "John Doe"
},
"metadata": {
"campaign_id": "camp_123"
}
}
}
The dynamic_variables inject into your agent's prompt (e.g., {{customer_name}}) , and metadata is stored with the call for your tracking.
---
### WEBHOOK FLOW
Exact sequence for inbound calls:
1. Call arrives at your Retell phone number
2. Retell `POST`s to your inbound webhook URL (configured on the phone number) with payload:
json
{
"event": "call_inbound",
"call_inbound": {
"agent_id": "agent_12345",
"agent_version": 1,
"from_number": "+12137771234",
"to_number": "+12137771235"
}
}AI Evy
12/30/2025, 10:41 AMoverride_agent_id, dynamic_variables, metadata, etc.
4. Call connects to the specified agent
5. Your existing call_started, call_ended, call_analyzed webhooks fire at those lifecycle points
[(3) ]()
**Yes, you can intercept before the call connects**—the inbound webhook fires before connection, giving you time to decide the agent and pass context.
[(1) ]()
While waiting for your webhook response, the call stays in ringing state.
---
### LEAD CREATION
Your approach is correct. Use the inbound webhook to:
, [(4) ]()
1. Look up caller by from_number
2. Create/update contact in your DB
3. Return metadata with campaign_id for tracking
4. Track the call in campaign_leads using data from call_ended or call_analyzed webhooks
This pattern is commonly used—fetch caller info from your CRM using the inbound webhook, inject as variables, and track via metadata.
---AI Evy
12/30/2025, 10:41 AMAI Evy
12/30/2025, 10:41 AMAI Evy
12/30/2025, 1:30 PMClient Nexus
12/30/2025, 1:30 PMAI Evy
12/30/2025, 1:31 PMretell-twilio or retell-telnyx) :
The webhook URL is configured on the phone number via Retell's API, not through Twilio directly. [(1) ]()
When you create or update a phone number through Retell, you set the inbound_webhook_url field:
javascript
inbound_webhook_url: "<https://example.com/inbound-webhook%22>
, [(2) ]()
This is the URL Retell will POST to when an inbound call arrives. [(1) ]()
How it works:
- Retell phone numbers automatically handle the telephony layer—Retell receives the call and triggers your inbound_webhook_url before connecting.
- You do not configure Twilio's VoiceUrl for Retell-managed numbers. Retell handles that routing internally.
For custom telephony (your own Twilio SIP trunk) :
If you imported a phone number via custom telephony, you configure the termination_uri and optionally inbound_webhook_url through Retell's Import Phone Number API. [(3) ]()
Summary:
- Retell phone numbers → set inbound_webhook_url via Retell API [(1) ]()
- Retell handles the call routing; Twilio's VoiceUrl is not used for Retell-managed numbersAI Evy
12/30/2025, 1:31 PMAI Evy
12/30/2025, 1:31 PMClient Nexus
12/30/2025, 1:31 PMAI Evy
12/30/2025, 1:31 PMAI Evy
12/30/2025, 1:31 PMinbound_webhook_url via the Update Phone Number API, Retell calls this webhook before connecting the call. [(1) ]()
The call stays in ringing state while waiting for your webhook response, giving you time to return override_agent_id and dynamic_variables.
### 2. Response Format Verification
Yes, your format is correct. Here's the documented structure:
json
{
"call_inbound": {
"override_agent_id": "agent_12345",
"override_agent_version": 1,
"dynamic_variables": {
"customer_name": "John Doe"
},
"metadata": {
"random_id": "12345"
}
}
}
All fields are optional.
### 3. Agent Override vs Override Agent ID
Both approaches are valid for different use cases:
- **`override_agent_id`**: Use this to switch between entirely different agents (e.g., business hours Agent A vs after-hours Agent B) . This is the correct approach for your time-based routing.
- **`agent_override`**: Use this to modify specific settings of the current agent without switching agents entirely—for example, changing begin_message, voice_id, or model_temperature for a single call.
If your business hours and after-hours agents have different prompts, voices, or tools, use override_agent_id. If they're the same agent with just a different greeting, you could use agent_override.retell_llm.begin_message.
### 4. Metadata Persistence
The metadata field is stored with the call object for your tracking purposes.
You can retrieve it later via the Get Call API.
### 5. Webhook Timeout
The webhook has a timeout of 10 seconds.
If no success status (2xx) is received within 10 seconds, the webhook will be retried up to 3 times.
Your 200-500ms database lookups are well within this limit.AI Evy
12/30/2025, 1:31 PMAI Evy
12/30/2025, 1:31 PM