Telnyx SIP Integration

How to integrate SIP Telnyx to Vapi

Integrate your Telnyx SIP trunk with Vapi.ai to enable your AI voice assistants to handle calls efficiently. This guide walks you through the complete setup process for both inbound and outbound calls.

1. Retrieve Your Vapi.ai Private Key

  • Log in to your Vapi.ai account
  • Navigate to Organization Settings
  • In the API Keys section, copy your Private Key

2. Configure Telnyx for Inbound Calls

To allow Telnyx to forward incoming calls to Vapi.ai:

  1. Create a SIP Trunk

    • Go to Voice / SIP Trunking / Create
    • Select FQDN
    • Click “Add FQDN”
    • Select A record type
    • Set FQDN to: sip.vapi.ai
    • Port should be 5060 by default
  2. Configure Inbound Settings

    • Navigate to the Inbound tab of your SIP trunk
    • Configure settings as shown:
  3. Assign Phone Number

    • Go to the Numbers tab
    • Assign your acquired phone number to the SIP trunk
  4. Configure SIP Invite

    • Go to Numbers, edit the number you’ll be using
    • Navigate to Voice settings
    • Scroll down to find “Translated Number”
    • Set this value to match your Vapi SIP URI

    This setting modifies the SIP Invite to the Vapi platform so invites are correctly routed to your Vapi SIP URI.

3. Configure Telnyx for Outbound Calls

To allow Vapi.ai to make outbound calls through your Telnyx account:

  1. Set Up Outbound Authentication

    • Go to Voice / SIP Trunking / Authentication and routing
    • Scroll down to “Outbound calls authentication”
    • Whitelist Vapi’s SIP server IPs:
      • 44.229.228.186
      • 44.238.177.138
    • Select Tech Prefix and create a new credential for Vapi to use
  2. Create Outbound Voice Profile

    • Go to Voice / Outbound Voice Profiles
    • Create a new profile
    • Name it appropriately
    • Configure desired destinations
    • Leave default configuration settings
    • Assign your SIP trunk
    • Complete setup

    Alternatively, go to your SIP trunk / Outbound tab and select your newly created outbound voice profile.

  3. Configure Outbound Settings

    • Choose the country you’ll be making most calls to

    We recommend creating a separate SIP Trunk for each country you aim to be making most calls to.

4. Add Your Telnyx SIP Credentials to Vapi.ai

Use the Vapi API to create a SIP trunk credential:

$curl -X POST https://api.vapi.ai/credential \
> -H "Content-Type: application/json" \
> -H "Authorization: Bearer YOUR_VAPI_PRIVATE_KEY" \
> -d '{
> "provider": "byo-sip-trunk",
> "name": "Telnyx Trunk",
> "gateways": [
> {
> "ip": "sip.telnyx.com"
> }
> ],
> "outboundAuthenticationPlan": {
> "authUsername": "YOUR_SIP_USERNAME",
> "authPassword": "YOUR_SIP_PASSWORD",
> "sipRegisterPlan": {
> "realm": "sip.telnyx.com"
> }
> }
> }'

Replace YOUR_VAPI_PRIVATE_KEY, YOUR_SIP_USERNAME, and YOUR_SIP_PASSWORD with your actual credentials.

If successful, the response will include an id for the created credential, which you’ll use in the next step.

5. Add Your Phone Number to Vapi.ai

Associate your phone number with the SIP trunk in Vapi.ai:

$curl -X POST https://api.vapi.ai/phone-number \
> -H "Content-Type: application/json" \
> -H "Authorization: Bearer YOUR_VAPI_PRIVATE_KEY" \
> -d '{
> "provider": "byo-phone-number",
> "name": "Telnyx SIP Number",
> "number": "YOUR_PHONE_NUMBER",
> "numberE164CheckEnabled": false,
> "credentialId": "YOUR_CREDENTIAL_ID"
> }'

Replace YOUR_VAPI_PRIVATE_KEY, YOUR_PHONE_NUMBER, and YOUR_CREDENTIAL_ID with your actual details.

6. Assign Your Voice Assistant to Handle Calls

  • In your Vapi.ai dashboard, go to the Build section and select Phone Numbers
  • Click on your Telnyx Number
  • In the Inbound Settings section, assign your voice assistant to handle incoming calls
  • In the Outbound Form section, assign your voice assistant to handle outgoing calls

7. Make Outbound Calls

To initiate outbound calls through your Telnyx SIP trunk:

$curl --location 'https://api.vapi.ai/call/phone' \
> --header 'Authorization: Bearer YOUR_VAPI_PRIVATE_KEY' \
> --header 'Content-Type: application/json' \
> --data '{
> "assistantId": "YOUR_ASSISTANT_ID",
> "customer": {
> "number": "CUSTOMER_PHONE_NUMBER",
> "numberE164CheckEnabled": false
> },
> "phoneNumberId": "YOUR_PHONE_ID"
> }'

Replace all placeholder values with your actual information.

By following these steps, your Telnyx SIP trunk will be fully integrated with Vapi.ai, allowing your AI voice assistants to manage calls effectively.