In this tutorial, we’ll guide you through connecting a custom telephony provider to Vapi, using Twilio as an example. The steps are quite similar for other telephony providers.
Set Up Termination (Outbound Calls): Configure the termination settings. The termination SIP URI here is crucial as it will be used in later steps.
Vapi’s SIP server have a static IP 44.229.228.186 and 44.238.177.138 . If you choose to whitelist IP addresses, ensure you whitelist the entire IP range as shown below:
After creating the Elastic SIP trunk, you need to purchase numbers or move existing numbers to this trunk.
To initiate outbound SIP calls, you first need to create a SIP trunk credential. This credential will serve as the foundation for establishing the connection between Vapi and your SIP provider.
curl -X POST <https://api.vapi.ai/credential> \\
-H "Content-Type: application/json" \\
-H "Authorization: Bearer your-private-key" \\
-d '{
"provider": "byo-sip-trunk",
"name": "Twilio Trunk",
"gateways": [
{
"ip": "your-gateway-id"
}
],
"outboundLeadingPlusEnabled": true
}'
This step sets up the SIP trunk credential, linking your telephony infrastructure with Vapi.
Once the SIP trunk credential is created, the next step is to create a phone number that will be associated with this SIP trunk. This phone number will be used to make outbound calls through the configured SIP trunk.
curl -X POST <https://api.vapi.ai/phone-number> \\
-H "Content-Type: application/json" \\
-H "Authorization: Bearer your-private-key" \\
-d '{
"provider": "byo-phone-number",
"name": "Twilio SIP Number",
"number": "your-sip-phone-number",
"numberE164CheckEnabled": false,
"credentialId": "your-credential-id-which-you-got-from-previous-step"
}'
This step creates a phone number that is directly associated with your SIP trunk, enabling you to manage and utilize it for outbound calls.
The phone number will be appeared in your dashboard you can trigger the call directly or if you want to trigger the call via API you can use that phone-number-id and trigger it.