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):
For step-by-step instructions for Telnyx or Twilio, see the following quickstarts:
- Purchase a phone number from your provider.
- Create a SIP trunk for your phone number.
- Add authentication or limit trunk usage by phone numbers or IP addresses.
- Associate your LiveKit SIP URI with your SIP trunk.
- 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.
The example uses the LiveKit CLI. For additional examples using the SDKs, see SIP inbound trunk.
Create a file named
inbound-trunk.json
with the following content:CautionReplace the phone number with the number you purchased from your SIP trunking provider.
{"trunk": {"name": "Demo inbound trunk","numbers": ["+15105550100"]}}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.
The example uses the LiveKit CLI. For additional examples using the SDKs, see SIP dispatch rule.
Create a file named
dispatch-rule.json
and add the following content:{"rule": {"dispatchRuleIndividual": {"roomPrefix": "call-"}}}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.
The example uses the LiveKit CLI. For additional examples using the SDKs, see SIP outbound trunk.
Create a file named
outbound-trunk.json
using your phone number, trunk domain name, and theusername
andpassword
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:
- Create a SIP inbound trunk.
- Create a SIP dispatch rule.
- Create an AI voice agent to accept phone calls.
To make outbound calls, use the following steps:
- Create a SIP outbound trunk.
- Create an AI voice agent to make phone calls or make an outbound call using the SIP API.