How to configure inbound calling on livekit? Does ...
# ask-ai
c
How to configure inbound calling on livekit? Does it go through a similar process as outbound ?
t
Thanks for reaching out, Subham. 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 to set up inbound calling on LiveKit together. Here’s a step-by-step guide to help you get started: 1. Set up a SIP Trunking Provider: First, you'll want to purchase a phone number from a SIP provider like Twilio or Telnyx. Then, configure it to send SIP traffic directly to your LiveKit SIP instance. 2. Create an Inbound Trunk: Next, use the LiveKit CLI or dashboard to create an inbound trunk linked to your purchased phone number. For example: `{ "trunk": { "name": "My inbound trunk", "numbers": ["+15105550100"] } }`Run this command:
lk sip inbound create inbound-trunk.json
. If you want, you can also restrict incoming calls to specific numbers by using the
allowedNumbers
field. 3. Create a Dispatch Rule: Now, define how incoming calls should be routed to LiveKit rooms and specify which agents or participants should join. For example: `{ "dispatch_rule": { "rule": { "dispatchRuleIndividual": { "roomPrefix": "call-" } }, "roomConfig": { "agents": [ { "agentName": "my-telephony-agent" } ] } } }`Then run:
lk sip dispatch create dispatch-rule.json
. 4. Answer the Call (for AI Agents): Once your agent connects, you can warmly greet the caller by using
session.generate_reply()
. For example:
Copy code
await session.generate_reply(
  instructions="Greet the user and offer your assistance."
)
Just a quick note: inbound calling works a bit differently from outbound. For inbound, you set up an inbound trunk and dispatch rules to accept and route calls, while outbound involves using an outbound trunk and programmatic APIs to initiate calls. Sources: Agents telephony integration | LiveKit Docs | Accepting inbound calls | LiveKit Docs | Accepting incoming calls | LiveKit Docs | SIP inbound trunk | LiveKit Docs | Agents telephony integration | LiveKit Docs