Creating a SIP trunk for inbound and outbound calls
Create a Twilio SIP trunk for incoming or outgoing calls, or both, using the following steps. To use the Twilio console, see Configure a SIP trunk using the Twilio UI.
For inbound calls, you can use TwiML for Programmable Voice instead of setting up Elastic SIP Trunking. To learn more, see Inbound calls with Twilio Voice.
Prerequisites
- Purchase phone number .
- Install the Twilio CLI .
- Create a Twilio profile to use the CLI.
Step 1. Create a SIP trunk
The domain name for your SIP trunk must end in pstn.twilio.com. For example, to create a trunk named My test trunk with the domain name my-test-trunk.pstn.twilio.com, run the following command:
twilio api trunking v1 trunks create \--friendly-name "My test trunk" \--domain-name "my-test-trunk.pstn.twilio.com"
The output includes the trunk SID. Copy it for use in the following steps.
Step 2: Configure your trunk
Configure the trunk for inbound calls or outbound calls or both. To create a SIP trunk for both inbound and outbound calls, follow the steps in both tabs:
For inbound trunks, configure an origination URI .
twilio api trunking v1 trunks origination-urls create \--trunk-sid <twilio_trunk_sid> \--friendly-name "LiveKit SIP URI" \--sip-url "sip:<your SIP endpoint>;transport=tcp" \--weight 1 --priority 1 --enabled
To restrict calls to a specific region, replace your global LiveKit SIP endpoint with a region-based endpoint.
For outbound trunks, configure username and password authentication using a credentials list. Complete the following steps using the Twilio console.
Step 1: Create a credential list
- Sign in to the Twilio console .
- Select Voice » Credential lists.
- Create a new credential list with the username and password of your choice.
Step 2: Associate the credential list with your SIP trunk
- Select Elastic SIP Trunking » Manage » Trunks and select the outbound trunk created in the previous steps.
- Select Termination » Authentication » Credential Lists and select the credential list you just created.
- Select Save.
Step 3: Associate phone number and trunk
The Twilio trunk SID and phone number SID are included in the output of previous steps. If you didn't copy the SIDs, you can list them using the following commands:
- To list phone numbers:
twilio phone-numbers list - To list trunks:
twilio api trunking v1 trunks list
twilio api trunking v1 trunks phone-numbers create \--trunk-sid <twilio_trunk_sid> \--phone-number-sid <twilio_phone_number_sid>
Configure a SIP trunk using the Twilio UI
Sign in to the Twilio console .
Create SIP Trunk on Twilio:
- Select Products & Services » Elastic SIP Trunking » Trunks.
- Select Create new SIP trunk, enter a name for your trunk, and select Create.
For inbound calls:
Select the Origination tab.
In the Origination URIs section, select Add new Origination URI.
In the Origination SIP URI field, enter your LiveKit SIP URI with
;transport=tcpappended. For example,sip:vjnxecm0tjk.sip.livekit.cloud;transport=tcp. You can find your SIP URI on the Project settings page or generate it from the CLI.Region-based endpointsTo restrict calls to a specific region, replace your global LiveKit SIP endpoint with a region-based endpoint.
Select Add.
For outbound calls, configure termination and authentication:
Select the Termination tab.
For the Termination SIP URI field, enter a unique domain name to identify your termination URI for the trunk.
Copy this Termination SIP URI to use when you create an outbound trunk for LiveKit.
Configure Authentication :
Select or create a Credential List with a username and password of your choice. The username and password must match the username and password you use for your LiveKit outbound trunk.
Select Save.
Next steps
Head back to the main setup documentation to finish connecting your SIP trunk to LiveKit.
SIP trunk setup
Configure your Twilio trunk in LiveKit.