Vapi is an advanced voice AI infrastructure that enables developers to integrate sophisticated voice capabilities into their applications. Vapi’s voice recognition, natural language understanding, and voice synthesis features help create more intuitive and engaging user interactions.

This guide outlines integrating Vapi with Plivo via SIP (Session Initiation Protocol). There are two key steps:

  1. Configuring outbound calls to ensure calls initiated from Vapi are routed through Plivo to the destination number.
  2. Configuring inbound calls to ensure calls received on a Plivo number are forwarded to Vapi via SIP.

Configuring outbound calls

Follow these steps to route outbound calls from Vapi through Plivo.

Step 1: Create an outbound SIP trunk in Plivo

  1. Log in to the Plivo console: Plivo Login.
  2. Navigate to Zentrunk (SIP)Outbound TrunkIP Access Control List: Access Control List.
  3. Create a new IP Access Control List.
  • Assign a name of your choice.
  • Whitelist the following Vapi IP addresses:
  • 44.229.228.186/32
  • 44.238.177.138/32

  1. Navigate to Create Outbound Trunks: Create Outbound Trunk.
  2. Provide a name and select the IP Access Control List created in the previous step.

  1. After creating the trunk, copy the termination SIP domain (e.g., ***********.zt.plivo.com).

  1. Follow the steps in this guide to purchase a number from Plivo.

Step 2: Configure Vapi with the outbound trunk

  1. Log in to the Vapi dashboard: Vapi Dashboard.
  2. Retrieve your Vapi API Key.

  1. Create a SIP trunk in Vapi using the Plivo termination SIP domain:
curl -X POST https://api.vapi.ai/credential \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer your-vapi-private-api-key" \
    -d '{
        "provider": "byo-sip-trunk",
        "name": "PLIVO Trunk",
        "gateways": [{ "ip": "***********.zt.plivo.com" }]
    }'

  1. Create a phone number and associate it with the newly created SIP trunk:
curl -X POST https://api.vapi.ai/phone-number \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer your-vapi-private-api-key" \
    -d '{
        "provider": "byo-phone-number",
        "name": "PLIVO SIP Number",
        "number": "1833684XXXX",
        "numberE164CheckEnabled": false,
        "credentialId": "a2c815b8-03f4-40f5-813c-xxxxxxxxxxxx"
    }'

  1. Note the phone number ID from the response.
  2. Follow this guide to create an assistant in Vapi.

Step 3: Make outbound calls from Vapi

Use the phone number ID, assistant ID, and a destination number to place an outbound call via the Vapi API.

curl --location 'https://api.vapi.ai/call/phone' \
    --header 'Authorization: Bearer your-vapi-private-api-key' \
    --header 'Content-Type: application/json' \
    --data '{
        "assistantId": "29d47d31-ba3c-451c-86ce-xxxxxxxxx",
        "customer": {
            "number": "9199437XXXXX",
            "numberE164CheckEnabled": false
        },
        "phoneNumberId": "eba2fb13-259f-4123-abfa-xxxxxxxxxxx"
    }'

The call should be routed through the Plivo trunk and successfully connect to the destination number.

Configuring Inbound Calls

Follow these steps to route inbound calls from Plivo to Vapi.

Step 1: Create an IP URI in Plivo

  1. Log in to the Plivo Console: Plivo Login.
  2. Navigate to Zentrunk (SIP)Inbound TrunksOrigination URI.
  3. Create a new IP URI with the following details.
    • Name: Choose a name.
    • URI: Enter the Vapi SIP URI: sip.vapi.ai;transport=udp.

Step 2: Create an inbound trunk in Plivo

  1. Navigate to Zentrunk (SIP)Inbound TrunksTrunksCreate New Inbound Trunk.
  2. Provide a name for the trunk.
  3. Select the Primary URI created in the previous step.
  4. Create the trunk.

Step 3: Attach a Plivo phone number to the inbound trunk

  1. Purchase or use an existing phone number from Plivo.
  2. Attach it to the newly created inbound trunk.

Now, any incoming calls to this number will be routed to Vapi using SIP trunking.