How do I setup both inbound and outbound calling o...
# ask-ai
l
How do I setup both inbound and outbound calling on the same server?
t
Thanks for reaching out, Mayur. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
To set up both inbound and outbound calling on the same server in LiveKit, follow these steps: • Step 1: Create an Inbound Trunk ◦ Configure your inbound trunk with your SIP provider (such as Telnyx or Twilio). ◦ Set up an FQDN connection for the inbound trunk and configure it to accept both inbound and outbound calls. • Step 2: Create an Outbound Trunk ◦ Create an outbound trunk using the LiveKit SIP API or Server SDK. ◦ Configure the outbound trunk with necessary details like address, transport, and authentication. • Step 3: Configure Dispatch Rules ◦ Create a dispatch rule using the SIP API or Server SDK. ◦ Set the dispatch rule to route inbound calls to a new room and to dispatch your agent there. • Step 4: Make Outbound Calls ◦ Use the SIP API or Server SDK to initiate outbound calls. ◦ Create a SIP participant with settings including phone number and SIP trunk ID. This setup allows inbound and outbound calls to coexist on the same server. You might need to adjust configuration based on your specific requirements. For more details, refer to the LiveKit documentation related to SIP trunks, dispatch rules, and calling features. Sources: Agents telephony integration | LiveKit Docs | Create and configure Telnyx SIP trunk | LiveKit Docs | Create and configure a Twilio SIP trunk | LiveKit Docs | lib/livekit/sip_service_client.rb | src/main/kotlin/io/livekit/server/SipServiceClient.kt | SIP overview | LiveKit Docs | Making calls using SIP | LiveKit Docs | SIP overview | LiveKit Docs
l
Right now I ran into an issue where when I make an outbound call, and a room is created, the webhook triggers even if no inbound call has been placed
t
Hey there! Let me break down what's happening with webhooks when you make an outbound call. It might seem a bit technical, but I'll help you understand. So, when you start an outbound call, LiveKit uses the
CreateSIPParticipant
API to invite your SIP trunk provider. Once they accept, a new room gets created automatically - even if no one else is there yet. Think of it like setting up a virtual meeting space just for that call. I know this might sound a bit unexpected, but it's totally normal. The outbound call itself is what kickstarts the room creation. If you want to get a bit more specific about these webhook events, you might want to add some custom logic on your end to tell the difference between outbound and inbound call events. No worries if that sounds complex - we can always help you figure out the best approach! Sources: Making outbound calls | LiveKit Docs | Webhooks | LiveKit Docs | livekit-protocol/livekit/protocol/webhook.pyi | protobufs/livekit_sip.proto | pkg/telemetry/events.go | test/integration/sip_test.go | packages/livekit-server-sdk/src/WebhookReceiver.test.ts | Agents telephony integration | LiveKit Docs | livekit-protocol/src/livekit.rs
l
In the current docs what differentiates between an inbound call and an outbound call in webhooks?
t
Hey there! Let me break down how you can easily tell the difference between inbound and outbound calls in LiveKit webhooks. It's pretty straightforward once you know what to look for. • SCD_INBOUND – this means an incoming call • SCD_OUTBOUND – this means an outgoing call • SCD_UNKNOWN – when the call direction is a bit of a mystery Pro tip: The
sip.ruleID
attribute is like a secret weapon for identifying inbound calls. It'll be filled in for inbound calls and blank for outbound ones. Quick summary to make your life easier: 1. Peek at the
call_direction
in the webhook event to see if it's coming or going. 2. Use
sip.ruleID
as your backup detective – it's got your back! Now you'll be able to handle and filter your calls like a pro. Hope this helps! Sources: SIP participant | LiveKit Docs | livekit/livekit_sip.pb.go
l
room { sid: "RM_3dMfsBSVJmFz" name: "Demo Room" empty_timeout: 300 creation_time: 1752059792 enabled_codecs { mime: "video/H264" } enabled_codecs { mime: "video/VP8" } enabled_codecs { mime: "video/VP9" } enabled_codecs { mime: "video/AV1" } enabled_codecs { mime: "audio/red" } enabled_codecs { mime: "audio/opus" } version { unix_micro: 1752059792280540 } departure_timeout: 20 creation_time_ms: 1752059792139 } id: "EV_WQBMSeRbxXRK" created_at: 1752059792 these are the info I get in event.
t
Hey there! Let me break down the room details for you in a way that's super easy to understand. Think of this like a quick tour of how we organize our room information. • sid: This is basically the room's unique name tag – kind of like its special ID. • name: What we're calling the room (like "Demo Room" – simple and straightforward). • empty_timeout: How long we'll wait before cleaning up an empty room. • creation_time: The exact moment this room came to life (in computer time). • enabled_codecs: The cool tech that helps your audio and video work smoothly (think H264, VP8, opus). • version: A little timestamp that helps us track the room's history. • departure_timeout: How we handle people leaving the room. • creation_time_ms: An extra precise timestamp, down to the millisecond. This is basically our room's personal blueprint – showing exactly how it's set up and configured. Oh, and just so you know, each event also comes with its own
id
and
created_at
timestamp to help us keep track of what's happening. Got questions? I'm all ears! Feel free to ask about any of these details, and I'll be happy to explain more. Sources: packages/livekit-rtc/src/proto/room_pb.ts
l
How do I know if it's inbound, outbound?
t
Hey there! Let me help you figure out how to tell if a call is coming in or going out. It's actually pretty straightforward – there are a few key fields you'll want to keep an eye on. •
sip.callDirection
: Think of this like a signpost that tells you the call's direction. It'll show either
SCD_INBOUND
(incoming call) or
SCD_OUTBOUND
(outgoing call). •
sip.ruleID
: This one's a bit of a tell for inbound calls – it'll have a dispatch rule ID. For outbound calls, it'll be blank. •
sip.trunkID
: This shows which SIP trunk was used for your call, whether it's coming in or going out. Pro tip: SIP participants will have
kind
set to
Participant.Kind == SIP
, and their
attributes
include cool details like
sip.callID
that can give you even more context. By checking out these fields in the event payload, you'll be a call direction detective in no time! Let me know if you need any more help understanding this. Sources: livekit-protocol/livekit/protocol/analytics.pyi | SIP participant | LiveKit Docs