Create and configure SIP trunk

Guidelines for creating inbound and outbound SIP trunks.

Create and configure SIP trunks with trunking provider

The general steps for creating a SIP trunk for LiveKit telephony apps are as follows (exact steps vary from provider to provider):

Note

For step-by-step instructions for Telnyx or Twilio, see the following quickstarts:

  1. Purchase a phone number from your provider.
  2. Create a SIP trunk for your phone number.
  3. Add authentication or limit trunk usage by phone numbers or IP addresses.
  4. Associate your LiveKit SIP URI with your SIP trunk.
  5. Associate a phone number with your SIP trunk.

Create inbound and outbound trunks in LiveKit

After you create a SIP trunk with your provider, create inbound and outbound LiveKit trunks to accept and make phone calls using an AI voice agent.

Create an inbound trunk

Create an inbound trunk to accept incoming phone calls.

Note

The example uses the LiveKit CLI. For additional examples using the SDKs, see SIP inbound trunk.

  1. Create a file named inbound-trunk.json with the following content:

    Caution

    Replace the phone number with the number you purchased from your SIP trunking provider.

    {
    "trunk": {
    "name": "Demo inbound trunk",
    "numbers": ["+15105550100"]
    }
    }
  2. Create the inbound trunk using lk:

    lk sip inbound create inbound-trunk.json

Create a dispatch rule

At least one dispatch rule is required to accept incoming calls using your LiveKit trunk. The following example creates a dispatch rule that puts each caller in an individual room.

Note

The example uses the LiveKit CLI. For additional examples using the SDKs, see SIP dispatch rule.

  1. Create a file named dispatch-rule.json and add the following content:

    {
    "rule": {
    "dispatchRuleIndividual": {
    "roomPrefix": "call-"
    }
    }
    }
  2. Create the dispatch rule using lk:

    lk sip dispatch create dispatch-rule.json

Create an outbound trunk

Create an outbound trunk to make outgoing phone calls.

Note

The example uses the LiveKit CLI. For additional examples using the SDKs, see SIP outbound trunk.

  1. Create a file named outbound-trunk.json using your phone number, trunk domain name, and the username and password required for SIP trunk authentication:

    {
    "trunk": {
    "name": "My outbound trunk",
    "address": "<my-trunk-domain-name>",
    "numbers": ["+15105550100"],
    "auth_username": "<username>",
    "auth_password": "<password>"
    }
    }

Next steps

To accept inbound calls, use the following steps:

  1. Create a SIP inbound trunk.
  2. Create a SIP dispatch rule.
  3. Create an AI voice agent to accept phone calls.

To make outbound calls, use the following steps:

  1. Create a SIP outbound trunk.
  2. Create an AI voice agent to make phone calls or make an outbound call using the SIP API.