https://retellai.com/?utm_source=discord&utm_medium=seo logo
How do I connect a Twilio toll free number to rete...
# ❓・ai-evy-support
f
@AI Evy How do I connect a Twilio toll free number to retell agent (for both calling and SMS)?
a
Thanks for tagging me @FZ. I'll look through relevant sources and get back to you shortly.
### Answer To connect a Twilio toll-free number to Retell AI for both voice calls and SMS, you need to set up Elastic SIP Trunking [(1) ]() . ## Step 1: Create Elastic SIP Trunking in Twilio Create the trunk in Twilio and configure it with a name and general settings . Setup Termination (for outbound calls) : - The termination SIP URI is important for later steps - Use a localized termination URI near your region - Whitelist IP addresses or create authentication with username and password - If using auth, you'll need to specify username and password when importing to Retell Setup Origination (for inbound calls) : - Specify Retell's SIP server address as the origination SIP URI:
sip:sip.retellai.com
## Step 2: Move Your Toll-Free Number to the Elastic SIP Trunk Purchase or move your existing toll-free number to this trunk in Twilio . ## Step 3: Import the Number to Retell You can import the number via the dashboard or programmatically using the Import Number API [(2) ]() [(1) ]() . When importing, provide: - `phone_number`: The toll-free number in E.164 format (e.g., "+18001234567") [(2) ]() - `termination_uri`: The termination SIP URI from Step 1 [(2) ]() [(1) ]() -
sip_trunk_auth_username
and `sip_trunk_auth_password`: If you configured authentication [(2) ]() - `inbound_agent_id`: Agent ID for handling inbound calls - `outbound_agent_id`: Agent ID for making outbound calls - `inbound_sms_agents`: Array of agents with weights for handling inbound SMS - `outbound_sms_agents`: Array of
agents with weights for outbound SMS Here's an example using the JavaScript SDK:
Copy code
javascript
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) ;
Once imported, the toll-free number will work for both inbound and outbound calls as well as SMS, just like a Retell-purchased number [(1) ]() [(3) ]() . ## Common Issues If outbound isn't working: - Check your Termination SIP URI for spaces and remove them [(1) ]() [(4) ]() - Use a localized termination URI near your region - Verify username and credentials are correct (username differs from the friendly name) For international dialing, search "geo" to find "Voice Geographic Permissions" in Twilio, select "Elastic Sip Trunking," and choose allowed countries .
​ To learn more, see the sources I considered: [[1] Twilio](https://docs.retellai.com/deploy/twilio) [[2] Import Phone Number](https://docs.retellai.com/api-references/import-phone-number) [[3] I’m trying to use a toll-free number (connected from Twilio through a SIP trunk)](https://community.retellai.com/t/i-m-trying-to-use-a-toll-free-number-connected-from-twilio-through-a-sip-trunk/127) [[4] Problem with outbounding call](https://community.retellai.com/t/problem-with-outbounding-call/514) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.