Is there any way I can get the call SID from Twili...
# ask-ai
m
Is there any way I can get the call SID from Twilio when I dispatch the agent to join the session? Where can I grab the Twilio SID?
t
Thanks for reaching out, Alexander. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hi there! Just to better assist you, could you let me know if you're using Twilio webhooks or SIP integration to start the call? Also, do you have access to Twilio’s incoming call events where the Call SID might be available? Understanding this will really help us figure out the best way to retrieve the Call SID during the agent dispatch process. Looking forward to your reply! Sources: README.md | packages/livekit-server-sdk/src/AgentDispatchClient.ts
m
SIP integration.
t
When you're working with SIP integration, LiveKit kindly maps the
X-Twilio-CallSid
SIP header to the participant attribute
sip.twilio.callSid
. You can easily find this attribute in the
participant_attributes
map, which is accessible either during dispatch rule evaluation or by checking participant information after your SIP participant joins a room. Here’s a simple way to retrieve it: • Use a LiveKit server SDK or make a direct RPC call to get participant or dispatch rule data. • Look into the
participant_attributes
map. • Grab the value of
sip.twilio.callSid
. For instance, in a Node.js agent, you could do something like this:
Copy code
// Check if the participant is a SIP participant and log the Twilio Call SID
if (participant.kind === Participant.Kind.SIP) {
  const callSid = participant.attributes['sip.twilio.callSid'];
  console.log('Twilio Call SID:', callSid);
}
Just a quick note: make sure you're using Twilio SIP Trunking, as this header is only available in those scenarios. If you have any questions or need a hand, feel free to reach out—I’m here to help! Sources: pkg/sip/participant.go | protobufs/rpc/sip.proto | README.md | packages/sip--um-actually/README.md | Create and configure a Twilio SIP trunk | LiveKit Docs