SIP trunk setup

Guide to setting up SIP trunks for inbound and outbound calls with LiveKit.

Overview

LiveKit is compatible with any SIP trunking provider. This guide provides general instructions for setting up a SIP trunk with an external provider and then associating it with your LiveKit project.

External provider setup

The usual steps to create a SIP trunk are as follows:

  1. Create a SIP trunk with your provider.
  2. Add authentication or limit trunk usage by phone numbers or IP addresses.
  3. Purchase a phone number and associate it with your SIP trunk.
  4. Add your LiveKit SIP URI to the SIP trunk.

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

LiveKit setup

Now you are ready to configure your LiveKit project to use the SIP trunk.

The following steps are common to all SIP trunking providers.

LiveKit CLI

These examples use the LiveKit CLI. For additional examples and full documentation, see the linked documentation for each component.

Inbound trunk setup

An inbound trunk allows you to accept incoming phone calls.

Create a temporary JSON file with your inbound trunk configuration, including the phone number you purchased from your SIP trunking provider.

{
"trunk": {
"name": "My inbound trunk",
"numbers": ["+15105550123"]
}
}

Use the LiveKit CLI to register the inbound trunk to your project.

lk sip inbound create inbound-trunk.json

Create a dispatch rule

You must set up at least one dispatch rule to accept incoming calls into a LiveKit room.

Create a temporary JSON file with your dispatch rule configuration. This example creates a dispatch rule that puts each caller into a randomly generated unique room using the name prefix call-. For many applications, this is the only configuration you need.

{
"rule": {
"dispatchRuleIndividual": {
"roomPrefix": "call-"
}
}
}

Use the LiveKit CLI to create the dispatch rule.

lk sip dispatch create dispatch-rule.json

Create an outbound trunk

Create an outbound trunk to make outgoing phone calls with LiveKit.

Create a temporary JSON file with your outbound trunk configuration. This example creates an outbound trunk with the phone number +55512345678 and the trunk domain name my-trunk-domain-name.

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

Use the LiveKit CLI to create the outbound trunk.

lk sip outbound create outbound-trunk.json

Now you are ready to place outgoing calls.

Next steps

See the following guides to continue building your telephony app.

Additional documentation

See the following documentation for more details on the topics covered in this guide.