Skip to main content

Overview

In this guide, we will show how to integrate Retell agents with your telephony providers and use your numbers. Please note that this is independent of the agent type you are using. We will provide two ways to integrate with your telephony provider:
  1. Elastic SIP trunking: This is the recommended way to integrate with your telephony provider that supports elastic SIP trunking. You will need to set up a SIP trunking and configure your number to point to it, and then import that number to Retell.
  2. Dial to SIP URI: If your telephony provider does not support elastic SIP trunking, or you have more complicated telephony setup that cannot use elastic SIP trunking, you can dial the call to a specific SIP uri.
  • Retell SIP server uri: sip:sip.retellai.com
  • IP block for United States traffic: 143.223.88.0/21, 161.115.160.0/19
You can use the IP block for US to whitelist the traffic to Retell’s SIP server. It’s commonly needed in a bunch of telephony providers. Currently there’s no static IP address block for traffic outside of US, but it’s under development.
Transport method supported:
  • UDP
  • TCP
  • TLS
For using the different transport for inbound calls, you can postpend the transport method to the sip server url:
  • For UDP, the sip server url needs to be sip:sip.retellai.com;transport=udp
  • For TCP, the sip server url needs to be sip:sip.retellai.com;transport=tcp
  • For TLS, the sip server url needs to be sip:5t4n6j0wnrl.sip.livekit.cloud;transport=tls
Media encryption supported:
  • SRTP
Elastic SIP Trunking is a service offered by cloud communications platforms that enables organizations to connect their existing PBX (Private Branch Exchange) or VoIP (Voice over IP) infrastructure to the Public Switched Telephone Network (PSTN) over the internet using the SIP (Session Initiation Protocol). In this context, the elastic SIP trunking is used to connect Retell’s VoIP with PSTN so that your agents can make and receive calls. When using this method, all the telephony functionalities that are supported by Retell numbers will also be supported here, assuming that your telephony provider supports it. SIP trunking is a popular service offered by many telephony providers, so most likely your telephony provider would be able to support this. Here’re detailed guides for some telephony providers:

Getting help

If you are using a telephony provider that requires static IP address, and we don’t have a static IP address block for your region, or you are having trouble setting the connection up, you can check out our partner Jambonz, where you can connect to Jambonz’s system that already connects with Retell (which supports static IP address, mutual TLS) and use their SIP trunking service. Dedicated slack support channel is available for Retell users.

FAQ

No, Retell will not be able to know if the setup you provide works or not until a call is made.
Please check your origination setting in your SIP trunking provider. Also check the logs in your telephony provider, and perhaps open a ticket with them.
Please check your termination setting in your SIP trunking provider, and make sure you provide the right termination url to Retell. Also check the logs in your telephony provider, and perhaps open a ticket with them.
Yes you can use the transfer call feature with SIP trunking. Please note that if you intend to use SIP REFER (cold transfer with the transferee’s number), you will need to configure that in your SIP trunking provider to allow SIP REFER and PSTN transfer, with the transferee’s number showing as caller id.
Yes, you can.
Yes, you can.
Right now you’d need to delete and re-import the number.

Method 2: Dial to SIP URI

If your telephony provider does not support elastic SIP trunking, or you have more complicated telephony setup that cannot use elastic SIP trunking, you can use this method. When using this method, Retell does not directly make or receive calls, but instead relies on your system to dial the call to the respective SIP URI. This would require you to have some codes to handle integration with your telephony provider. All traffic looks like inbound to Retell in this case, so it’s up to you to specify the call direction.
When using this method, you will not be able to utilize Retell’s transfer call feature, as we do not have access and control over the telephony provider and number, and cannot initiate transfer for you. You can however implement your own transfer logic and use a custom function to trigger a call transfer.
Here we assume you already have your call handling setup. For Retell to know what agent to use to handle the call, and for you to obtain SIP URI to use for this call, you would call the Register Phone Call API. You will get a call_id back from this API, and you would use it to piece together the SIP URI.
SIP URI: sip:{call_id}@sip.retellai.com

Example Code

Here’s an overly simplified example code to handle the inbound call webhook from Twilio and dialing the call to the SIP URI.
Node
const client = new Retell({
  apiKey: 'YOUR_RETELL_API_KEY',
});

server.app.post(
  "/voice-webhook",
  async (req: Request, res: Response) => {
    // Register the phone call to get call id
    const phoneCallResponse = await client.call.registerPhoneCall({
      agent_id: 'oBeDLoLOeuAbiuaMFXRtDOLriTJ5tSxD',
      from_number: "+12137771234", // optional
      to_number: "+12137771235", // optional
      direction: "inbound", // optional
    });

    // Start phone call websocket
    const voiceResponse = new VoiceResponse();
    const dial = voiceResponse.dial();
    dial.sip(
      `sip:${phoneCallResponse.call_id}@sip.retellai.com`,
    );
    res.set("Content-Type", "text/xml");
    res.send(voiceResponse.toString());
  },
);

FAQ

You will need to handle the transfer call/end call logic yourself, meaning that you will need to write a custom function which internally interacts with your telephony provider to transfer the call/end the call.
Yes.
Check your code that interacts with telephony provider. Some provider like Twilio can call the webhook multiple times for a single call. In those cases, you will need to dedupe the call.
Yes, using this method basically gives you full control over telephony functionalities, so you should be able to use telephony provider’s other features.

Video Tutorials

Elastic SIP Trunking

Twilio
Telnyx
Vonage

Dial to SIP URI

I