princepappiah_68836
10/27/2025, 8:57 AMAI Evy
10/27/2025, 8:57 AMAI Evy
10/27/2025, 8:57 AMAI Evy
10/27/2025, 8:57 AMAI Evy
10/27/2025, 8:57 AMprincepappiah_68836
10/27/2025, 8:59 AMprincepappiah_68836
10/27/2025, 9:00 AMprincepappiah_68836
10/27/2025, 9:00 AMAI Evy
10/27/2025, 9:00 AMAI Evy
10/27/2025, 9:00 AMcall_id, then construct the SIP URI as sip:{call_id}@sip.retellai.com .
Here's the code example:
javascript
const client = new Retell({
apiKey: 'YOUR_RETELL_API_KEY',
}) ;
const phoneCallResponse = await client.call.registerPhoneCall({
agent_id: 'oBeDLoLOeuAbiuaMFXRtDOLriTJ5tSxD',
from_number: "+12137771234",
to_number: "+12137771235",
direction: "inbound",
}) ;
const voiceResponse = new VoiceResponse() ;
const dial = voiceResponse.dial() ;
dial.sip(
`sip:${phoneCallResponse.call_id}@sip.retellai.com`,
) ;
The SIP server URI is sip:sip.retellai.com, and the IP block for United States traffic is 143.223.88.0/21, 161.115.160.0/19 . You can use different transport methods by appending to the SIP server URL (UDP, TCP, or TLS) .
The key difference when moving to Telnyx is in your telephony provider configuration, not in how you register calls with Retell . The Register Phone Call API and SIP URI construction remain the same regardless of whether you're using Twilio, Telnyx, or any other provider .AI Evy
10/27/2025, 9:00 AMAI Evy
10/27/2025, 9:00 AMprincepappiah_68836
10/27/2025, 9:03 AMprincepappiah_68836
10/27/2025, 9:06 AMAI Evy
10/27/2025, 9:06 AMAI Evy
10/27/2025, 9:06 AMdial_failed error after switching to Telnyx [(1) ]() .
When you get dial_failed as a disconnection reason, it means "Outbound call not connected, dialing failed with no or unknown sip error code" .
The code for registering calls doesn't change when switching from Twilio to Telnyx. The Register Phone Call API works the same way regardless of your telephony provider [(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',
}) ;
console.log(phoneCallResponse.agent_id) ;
What likely needs to change:
1. Your Telnyx number configuration - Ensure your Telnyx number is properly imported into Retell with the correct SIP trunk settings
2. The from_number parameter - This must be your Telnyx number (in E.164 format) that's registered with Retell [(2) ]() [(3) ]()
3. SIP trunk credentials - If using custom telephony with Telnyx, verify your termination SIP URI and authentication credentials are correct
Could you share the actual code snippet you're using? That would help me identify the specific issue. Also, have you properly imported your Telnyx number into Retell through the dashboard or API?AI Evy
10/27/2025, 9:06 AMAI Evy
10/27/2025, 9:06 AMprincepappiah_68836
10/27/2025, 9:07 AMAI Evy
10/27/2025, 9:07 AMAI Evy
10/27/2025, 9:07 AMjavascript
import Retell from 'retell-sdk';
const client = new Retell({
apiKey: 'YOUR_RETELL_API_KEY',
}) ;
const phoneCallResponse = await client.call.registerPhoneCall({
agent_id: 'oBeDLoLOeuAbiuaMFXRtDOLriTJ5tSxD',
}) ;
console.log(phoneCallResponse.agent_id) ;
What you need to change:
1. from_number - This must be your Telnyx number (in E.164 format like "+14157774444") that you've imported to Retell
2. Number import configuration - Ensure your Telnyx number is properly imported with the correct termination SIP URI from your Telnyx SIP trunk [(2) ]()
Common causes of dial_failed errors:
- The from_number isn't properly configured in Retell
- The termination SIP URI has spaces (remove them) [(3) ]()
- Authentication credentials are incorrect
- The number hasn't been imported to Retell yet
Once you share your code snippet, I can identify the specific issue causing the dial failures.
**AI Evy
10/27/2025, 9:07 AMAI Evy
10/27/2025, 9:07 AMprincepappiah_68836
10/27/2025, 9:10 AMInitiating Retell call for debtor with contact: ${debt.contact_number});
let callResponse = await retellClient.call.registerPhoneCall({
agent_id: this.agentId,
from_number: phoneNumber,
to_number: debt.contact_number,
direction: "outbound",
retell_llm_dynamic_variables: debt,
});
// console.log("Retell call response:", callResponse);
const callId = callResponse.call_id;
const sipEndpoint = `sip:${callId}@5t4n6j0wnrl.sip.livekit.cloud`;
// console.log(Initiating Twilio call for SIP Endpoint: ${sipEndpoint});
const call = await twilioClient.calls.create({
url: ${process.env.BASE_URL}/twilio-webhook?sipEndpoint=${encodeURIComponent(sipEndpoint)},
to: debt.contact_number,
from: phoneNumber,
});
// console.log("Twilio call response:", call);
const extendedCallResponse: any = {
...callResponse,
start_timestamp: new Date().getTime(),
end_timestamp: new Date().getTime(),
call_duration: '00:00:00',
call_progress: "Ringing",
_id: debt._id, // Ensure to pass an identifier for updating later if needed.
};
// console.log("Extended call response:", extendedCallResponse);
successfulCalls.push(extendedCallResponse);
....AI Evy
10/27/2025, 9:10 AMAI Evy
10/27/2025, 9:10 AMtwilioClient to initiate the call even though you've switched to Telnyx [(1) ]() .
When using the "Dial to SIP URI" method with Telnyx, you need to replace the Twilio client call with your Telnyx equivalent. The Retell-specific code stays the same :
What stays the same (Retell side) :
javascript
let callResponse = await retellClient.call.registerPhoneCall({
agent_id: this.agentId,
from_number: phoneNumber,
to_number: debt.contact_number,
direction: "outbound",
retell_llm_dynamic_variables: debt,
}) ;
[(2) ]()
What needs to change:
Replace this Twilio-specific code:
javascript
const call = await twilioClient.calls.create({
url: `${process.env.BASE_URL}/twilio-webhook?sipEndpoint=${encodeURIComponent(sipEndpoint) }`,
to: debt.contact_number,
from: phoneNumber,
}) ;
With your Telnyx equivalent that dials to the SIP endpoint. You'll need to use Telnyx's SDK to initiate the call and direct it to the SIP URI sip:${callId}@sip.retellai.com [(1) ]() .
Key points:
- The SIP server URI for Retell is sip:sip.retellai.com
- The Register Phone Call API returns a call_id that you use to construct the SIP URI as sip:{call_id}@sip.retellai.com
- Your from_number (phoneNumber variable) must be your Telnyx number that's properly imported into Retell [(2) ]()
The dial_failed errors are happening because you're still using the Twilio client to make calls, but your number is now with Telnyx. You need to replace the Twilio SDK calls with Telnyx SDK calls to actually initiate the call through Telnyx's network.
**AI Evy
10/27/2025, 9:10 AMAI Evy
10/27/2025, 9:10 AMprincepappiah_68836
10/27/2025, 9:15 AMAI Evy
10/27/2025, 9:15 AMAI Evy
10/27/2025, 9:15 AMtypescript
import express, { Request, Response } from 'express';
app.post("/telnyx-webhook", (req: Request, res: Response) => {
const sipEndpoint = req.query.sipEndpoint as string;
// Telnyx uses TeXML (similar to TwiML but Telnyx-specific)
const texml = `<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Dial>
<Sip>${sipEndpoint}</Sip>
</Dial>
</Response>`;
res.set("Content-Type", "text/xml") ;
res.send(texml) ;
}) ;
Key points:
- The SIP endpoint construction stays the same: sip:${callId}@sip.retellai.com
- Telnyx uses TeXML format (similar structure to TwiML) [(2) ]()
- The webhook URL needs to be configured in your Telnyx number settings instead of Twilio
- Your from_number in the Register Phone Call API must be your Telnyx number
*Alternative: Use Elastic SIP Trunking (Recommended) *
Instead of the webhook approach, Telnyx supports Elastic SIP Trunking, which is the recommended method [(1) ]() [(2) ]() . With this approach:
1. Create an Elastic SIP Trunk in Telnyx with FQDN sip.retellai.com [(2) ]()
2. Move your numbers to this trunk
3. Import the numbers to Retell via dashboard or API
This eliminates the need for webhooks entirely and provides better reliability .
---
**AI Evy
10/27/2025, 9:15 AMAI Evy
10/27/2025, 9:15 AMprincepappiah_68836
10/27/2025, 9:23 AMAI Evy
10/27/2025, 9:23 AMAI Evy
10/27/2025, 9:23 AMsip.retellai.com
2. Import your Telnyx number to Retell using the Import Phone Number API [(1) ]()
typescript
import Retell from 'retell-sdk';
const client = new Retell({
apiKey: 'YOUR_RETELL_API_KEY',
}) ;
const phoneNumberResponse = await client.phoneNumber.import({
phone_number: '+14157774444',
termination_uri: 'someuri.pstn.twilio.com',
}) ;
console.log(phoneNumberResponse.inbound_agent_id) ;
3. Use the Create Phone Call API for outbound calls instead of the webhook approach
With Elastic SIP Trunking, you don't need to configure webhooks in Telnyx at all - the SIP trunk handles the routing automatically.
If you must use the webhook approach, you would need to configure the webhook URL in your Telnyx number settings through the Telnyx dashboard (similar to how you configured it in Twilio's phone number settings) . However, this configuration is Telnyx-specific and outside of Retell AI's documentation scope.
Would you like help setting up the Elastic SIP Trunking method instead? It's more reliable and eliminates the webhook complexity.
---AI Evy
10/27/2025, 9:23 AMAI Evy
10/27/2025, 9:23 AMprincepappiah_68836
10/27/2025, 9:24 AMAI Evy
10/27/2025, 9:24 AMAI Evy
10/27/2025, 9:24 AMtypescript
import express, { Request, Response } from 'express';
app.post("/telnyx-webhook", (req: Request, res: Response) => {
const sipEndpoint = req.query.sipEndpoint as string;
// Telnyx uses TeXML format
const texml = `<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Dial>
<Sip>${sipEndpoint}</Sip>
</Dial>
</Response>`;
res.set("Content-Type", "text/xml") ;
res.send(texml) ;
}) ;
3. Your call initiation code stays mostly the same:
typescript
let callResponse = await retellClient.call.registerPhoneCall({
agent_id: this.agentId,
from_number: phoneNumber, // Your Telnyx number
to_number: debt.contact_number,
direction: "outbound",
retell_llm_dynamic_variables: debt,
}) ;
const callId = callResponse.call_id;
const sipEndpoint = `sip:${callId}@sip.retellai.com`;
// Use Telnyx SDK instead of Twilio
const call = await telnyxClient.calls.create({
connection_id: 'YOUR_TELNYX_CONNECTION_ID',
to: debt.contact_number,
from: phoneNumber,
webhook_url: `${process.env.BASE_URL}/telnyx-webhook?sipEndpoint=${encodeURIComponent(sipEndpoint) }`,
}) ;AI Evy
10/27/2025, 9:25 AMtwilioClient with telnyxClient
- Use connection_id instead of Twilio's authentication
- Use webhook_url parameter in the call creation
- The SIP endpoint remains sip:${callId}@sip.retellai.com [(2) ]()
The webhook logic is essentially the same - you're routing the call to Retell's SIP server. The main change is switching from Twilio's SDK to Telnyx's SDK for initiating calls.AI Evy
10/27/2025, 9:25 AMAI Evy
10/27/2025, 9:25 AMprincepappiah_68836
10/27/2025, 10:52 AMAI Evy
10/27/2025, 10:52 AMAI Evy
10/27/2025, 10:53 AMconnection_id is a Telnyx-specific identifier that you need to obtain from your Telnyx dashboard. This is not part of Retell AI's configuration - it's specific to Telnyx's API.
To find your Telnyx Connection ID:
1. Log into your Telnyx dashboard
2. Navigate to "Voice" → "Connections" or "SIP Connections"
3. Find the connection you created for your phone number
4. Copy the Connection ID (it's typically a UUID format like 1234567890abcdef)
However, based on the Retell AI documentation for Telnyx integration, the recommended approach is Elastic SIP Trunking, which doesn't require managing connection IDs in your code [(1) ]() .
With Elastic SIP Trunking:
- You configure the trunk in Telnyx with FQDN sip.retellai.com
- You import the number to Retell using the Import Phone Number API
- You then make calls using Retell's Create Phone Call API without needing to interact with Telnyx's SDK directly
If you're committed to the webhook approach, the connection_id is found in your Telnyx dashboard under your SIP connection settings. This is Telnyx-specific configuration that's outside the scope of Retell AI's documentation.
The Retell AI side remains the same - you register the call and get the SIP endpoint sip:{call_id}@sip.retellai.com .
---AI Evy
10/27/2025, 10:53 AMAI Evy
10/27/2025, 10:53 AMprincepappiah_68836
10/27/2025, 10:54 AMAI Evy
10/27/2025, 10:54 AMAI Evy
10/27/2025, 10:54 AMAI Evy
10/27/2025, 10:55 AMAI Evy
10/27/2025, 10:55 AMAI Evy
10/27/2025, 10:55 AMprincepappiah_68836
10/27/2025, 11:16 AMAI Evy
10/27/2025, 11:16 AMAI Evy
10/27/2025, 11:16 AMAI Evy
10/27/2025, 11:16 AMAI Evy
10/27/2025, 11:16 AMprincepappiah_68836
10/27/2025, 5:00 PMAI Evy
10/27/2025, 5:00 PMAI Evy
10/27/2025, 5:01 PMtypescript
await Promise.all(
debts.map(async (debt) => {
try {
// Use Create Phone Call API instead of Register + Webhook
let callResponse = await retellClient.call.createPhoneCall({
from_number: phoneNumber, // Your Telnyx number imported to Retell
to_number: debt.contact_number,
override_agent_id: this.agentId, // Use override_agent_id instead of agent_id
retell_llm_dynamic_variables: debt,
}) ;
const extendedCallResponse: any = {
...callResponse,
start_timestamp: new Date() .getTime() ,
end_timestamp: new Date() .getTime() ,
call_duration: '00:00:00',
call_progress: "Ringing",
_id: debt._id,
};
successfulCalls.push(extendedCallResponse) ;
} catch (error) {
console.error(`Failed to create call for ${debt.contact_number}:`, error) ;
}
})
) ;AI Evy
10/27/2025, 5:01 PMregisterPhoneCall with createPhoneCall
2. Remove all Telnyx SDK code (telnyxClient.calls.create) [(2) ]()
3. Remove the webhook endpoint (/telnyx-webhook) - you don't need it anymore
4. Use override_agent_id parameter instead of agent_id [(1) ]()
5. Ensure from_number is your Telnyx number that's already imported to Retell [(3) ]()
That's it! With Elastic SIP Trunking, Retell handles all the telephony routing automatically through your configured SIP trunk [(4) ]() [(2) ]() . You don't need to manage SIP endpoints, webhooks, or interact with Telnyx's SDK at all [(2) ]() .
The call will be initiated through your Telnyx SIP trunk automatically, and you'll get the call response back from Retell with all the call details [(1) ]() .AI Evy
10/27/2025, 5:01 PMAI Evy
10/27/2025, 5:01 PM