https://retellai.com/?utm_source=discord&utm_medium=seo logo
Hi,I have Retell connected to Twilio via Elastic S...
# ❓・ai-evy-support
g
@AI Evy Hi, I have Retell connected to Twilio via Elastic SIP Trunk. Call transfers to SIP extensions are failing and I need help. Setup: ∙ Twilio Elastic SIP Trunk → Retell agent (inbound works perfectly) ∙ Twilio Programmable SIP Domain with /router webhook for extension routing ∙ Transfer mode: sip_refer to sip:1700@[mysip].sip.twilio.com What happens: 1. Caller dials in → Retell agent answers ✅ 2. Agent sends SIP REFER → Twilio creates child call leg to sip:1700@[mysip].sip.twilio.com ✅ 3. Child call routes through the Elastic SIP Trunk ❌ 4. Trunk treats 1700 as a PSTN number → fails with error 32009 ❌ 5. Phone number voice URL never called ❌ 6. SIP domain /router webhook never called ❌ Also tried: sip_invite mode — the INVITE never leaves Retell’s infrastructure at all. Nothing reaches Twilio. Questions: 1. Is there a supported way to transfer from a Retell agent to SIP extensions on a Twilio Programmable SIP Domain when the number is on an Elastic SIP Trunk? 2. Why does sip_invite never send anything to Twilio? 3. What is the correct architecture for Retell → Twilio SIP extension transfers?
a
Thanks for tagging me @gphan.. I'll look through relevant sources and get back to you shortly.
l DIDs instead of trying to reach internal extensions directly .
​ To learn more, see the sources I considered: [[1] Solved, call transfers are now routing my calls to extensions](https://community.retellai.com/t/solved-call-transfers-are-now-routing-my-calls-to-extensions/723) ​
### Answer Based on the available sources, Retell AI can only transfer calls to full PSTN numbers or SIP entry points, not directly to internal PBX extensions [(1) ]() . This is the core limitation you're encountering. ## Why Your Current Setup Fails When using Elastic SIP Trunking with Twilio, the SIP REFER you're sending (
sip:1700@[mysip].sip.twilio.com
) is being routed back through the trunk, which treats
1700
as a PSTN number rather than an internal extension . This causes the 32009 error you're seeing. ## Supported Architecture The recommended approach is to transfer the call back to your PBX via a dedicated DID or SIP trunk, then let the PBX route internally using IVR logic, language flags, or call context . Specifically, your PBX needs to expose routing numbers (DIDs or equivalent) that map to specific extensions or queues . When the AI hands off the call, it's sent back to one of those numbers, and the PBX handles the internal routing . ## Alternative: Custom SIP Headers If your PBX supports SIP headers, you can pass intent or language metadata and route dynamically . Retell supports adding custom SIP headers for outbound calls, which are forwarded to your SIP provider on the SIP INVITE and can be used for custom routing, tagging, or metadata . ## Why SIP INVITE Mode Doesn't Work The sources don't provide specific details about why
sip_invite
mode isn't reaching Twilio in your case, but the fundamental issue remains: Retell cannot transfer directly to internal extensions . The transfer must go to a full PSTN number or a properly configured SIP entry point that your telephony provider recognizes. ## Recommended Solution Configure your Twilio setup so that specific DIDs route to your extensions, then have Retell transfer to those ful
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
g
@AI Evy When Gretchen transfers to a PSTN number via SIP REFER, the call loops back through the trunk origination and Gretchen answers again instead of routing to an extension. My setup: Twilio Elastic SIP Trunk with origination URI pointing to sip.retellai.com One Twilio number on the trunk Retell agent handles inbound calls Transfer destination is a second Retell-owned number The problem: SIP REFER transfer → goes out trunk termination → hits PSTN → arrives back at Retell number → Gretchen answers again (loop) What I need: When Gretchen transfers, the transferred call needs to hit a Twilio webhook (/retell-inbound) that routes to SIP extensions. Specific questions: Can a Retell-owned number's inbound_webhook_url be set to a custom URL so it hits my webhook instead of an agent? Is there any way for Gretchen to trigger a transfer that hits a Twilio voice URL webhook directly instead of going through the trunk? Has anyone successfully implemented Retell → Twilio SIP extension transfers with Elastic SIP Trunk? What was the exact architecture?
a
Thanks for the follow-up, @gphan.. I'll get back to you soon.
### Answer Based on the available sources, here's what I can address about your setup: ## Inbound Webhook URL Configuration Yes, you can set a custom
inbound_webhook_url
on a Retell-owned number [(1) ]() . The webhook allows you to override agent ID, set dynamic variables, and configure other fields specific to that call . When configured, this webhook is triggered for inbound calls before routing to an agent . You can set this via the Update Phone Number API with the
inbound_webhook_url
parameter :
Copy code
javascript
inbound_webhook_url: "<https://example.com/inbound-webhook%22>
## Inbound Webhook Payload When an inbound call arrives, the webhook receives information including the caller's number [(2) ]() :
Copy code
{
  "call_inbound": {
    "agent_id": "agent_12345",
    "from_number": "+12137771234",
    "to_number": "+12137771235"
  }
}
## Important Limitation The sources don't provide specific guidance on preventing transfer loops when transferring between Retell numbers or routing transferred calls to Twilio webhooks instead of agents. The documentation covers basic SIP trunking setup [(3) ]() [(4) ]() and inbound webhook configuration [(1) ]() , but doesn't address the specific architecture you're trying to implement. For your exact use case (Retell → Twilio webhook → SIP extensions with Elastic SIP Trunk) , I don't have information about a supported pattern in the available sources. I'd recommend checking out these potentially useful sources: [Custom Telephony Overview]() , [Update Phone Number]() Would you like a general answer based on my knowledge instead?
​ To learn more, see the sources I considered: [[1] Update Phone Number](https://docs.retellai.com/api-references/update-phone-number) [[2] Discord message from @ross_48077 on 2025-04-16](https://discord.com/channels/1186424376300679209/1186462578310910112/1361862052586459156) [[3] Custom Telephony Overview](https://docs.retellai.com/deploy/custom-telephony) [[4] AI in SIP Calling & Telephony Solutions | Retell AI](https://www.retellai.com/blog/integrating-ai-with-sip-trunking-and-modern-telephony) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
g
@AI Evy When Gretchen does a warm transfer to a Retell-owned number (+13523202240), the call goes out via Twilio trunk termination as a PSTN call. It arrives at Retell as a regular inbound call and Gretchen answers it again (loop). The inbound_webhook_url set on +13523202240 does not fire. Question: When a call arrives at a Retell-owned number via PSTN (not via Retell's own SIP infrastructure), does the inbound_webhook_url fire? Or does it only fire for calls routed through Retell's internal system? Bigger question: What is the correct architecture for transferring from a Retell agent to physical SIP desk phones/extensions when the main number is on a Twilio Elastic SIP Trunk? We cannot transfer directly to SIP URIs (trunk intercepts). We cannot use a second number without buying one. What do other people do in this situation?
a
Thanks for the follow-up, @gphan.. I'll get back to you soon.
### Answer Based on the available sources, the
inbound_webhook_url
should fire for regular inbound calls to a Retell number [(1) ]() . However, the sources don't explicitly address whether this webhook fires when a call arrives via PSTN transfer versus through Retell's internal routing. ## Inbound Webhook Configuration The
inbound_webhook_url
can be set on any phone number (including imported numbers) via the Update Phone Number API :
Copy code
javascript
inbound_webhook_url: "<https://example.com/inbound-webhook%22>
The webhook receives call information including
from_number
and
to_number
[(2) ]() . According to community sources, this webhook fires when calls start and provides the caller's number in the payload . ## Transfer Limitations with Elastic SIP Trunking When using Elastic SIP Trunking with Twilio, transfers face specific constraints. For cold transfers with "Transferee's Number" selected, Retell uses SIP REFER protocol, which requires your telephony provider to support SIP REFER, enable transfer to PSTN, and set caller ID as transferee [(3) ]() . However, Twilio does not honor custom SIP headers in REFER requests for cold transfers . The sources indicate that when using custom telephony via Elastic SIP Trunking, Retell does not directly make or receive calls but relies on your system to dial calls to the respective SIP URI [(4) ]() . Transfer functionality depends on your SIP trunk configuration . ## Architecture Gap The sources don't provide a documented pattern for transferring from a Retell agent to internal SIP extensions when using Elastic SIP Trunking without purchasing additional numbers. The transfer call feature requires proper SIP trunk configuration to allow SIP REFER and PSTN transfer . I'd recommend checking out these potentially useful sources: [Custom Telephony Overview]() , [Update Phone Number]() Would you like a general answer based on my knowledge instead?
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
​ To learn more, see the sources I considered: [[1] Update Phone Number](https://docs.retellai.com/api-references/update-phone-number) [[2] there is no doumentation on when a inbound sip call is answered, how to find the callers number](https://discord.com/channels/1186424376300679209/1318909532008878121) [[3] Help on Twilio DID questions](https://community.retellai.com/t/help-on-twilio-did-questions/24) [[4] Custom Telephony Overview](https://docs.retellai.com/deploy/custom-telephony) ​