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.

1. Create Elastic SIP Trunking

  1. Create the Trunk: Start by creating a new trunk, assigning it a name, and adjusting the general settings as needed.

image.png

  1. Set Up Termination (Outbound Calls): Configure the termination settings. The termination SIP URI here is crucial as it will be used in later steps.

    image.png

    image.png

    image.png

2. Move Numbers to Elastic SIP Trunking

After creating the Elastic SIP trunk, you need to purchase numbers or move existing numbers to this trunk.

image.png

3. Trigger the Outbound Call from Vapi

  1. Create a SIP Trunk Credential

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"
        }
    ]
}'

This step sets up the SIP trunk credential, linking your telephony infrastructure with Vapi.

  1. Create a Phone Number Associated with the SIP Trunk

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.

4. Start Making 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.