I self host the livekit sip server, but I want to ...
# ask-ai
m
I self host the livekit sip server, but I want to know about how to connect my agent with a twilio sip trunk
t
Thanks for reaching out, David. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Let's walk through how you can connect your LiveKit SIP server with a Twilio SIP trunk. I’m here to help make this as smooth as possible for you: 1. Create a SIP Trunk in Twilio: Start by using the Twilio CLI to create a SIP trunk with a domain ending in
pstn.twilio.com
. Keep a note of the trunk SID—you’ll need it later. 2. Configure the Trunk: Next, set up the trunk to route calls to your LiveKit SIP URI. This URI should look like
sip:<host>;transport=tcp
, which you can get from your
LIVEKIT_SIP_URI
environment variable. 3. Associate a Phone Number: Link a Twilio phone number to your SIP trunk to manage incoming calls. You can do this easily using the Twilio CLI or API. 4. Set Up SIP Credentials: For secure authentication, create a SIP credentials list in Twilio and associate it with your trunk. Add your username and password through the Twilio Console. 5. Configure LiveKit: Finally, use the LiveKit server SDK to create an inbound SIP trunk and set up a dispatch rule to route incoming calls to the right rooms. Don’t forget to ensure all the necessary environment variables are set, like
LIVEKIT_SIP_URI
,
TWILIO_ACCOUNT_SID
, and
TWILIO_AUTH_TOKEN
. If you want to dive deeper or automate the process, the livekit-sip-agent-example repository is a fantastic resource. Sources: Create and configure a Twilio SIP trunk | LiveKit Docs | src/setup-livekit.ts | packages/sip--um-actually/README.md