can you extract the twilio call sid from livekits ...
# ask-ai
l
can you extract the twilio call sid from livekits room information or from job context?
t
Thanks for reaching out, Daniel. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
The Twilio Call SID can be extracted from LiveKit's room information when using Twilio SIP trunks. SIP participants include Twilio-specific attributes in their
attributes
field, such as: •
sip.twilio.accountSid
- Twilio account SID •
sip.twilio.callSid
- Twilio call SID To extract the Twilio Call SID, you can check if a participant is a SIP participant and then access the appropriate attribute. Here's an example in Node.js:
Copy code
if (participant.kind == ParticipantKind.SIP) {
    console.log(participant.attributes['sip.twilio.callSid']);
}
Additionally, in agent applications, you can access this information through the job context by retrieving participants from the room. The job context provides access to the room object, which contains all participants and their attributes. Please note that the Twilio Call SID is only available when using Twilio SIP trunks. For other SIP trunk providers, different provider-specific attributes may be available. Sources: SIP participant | LiveKit Docs | livekit-agents/livekit/agents/job.py
l
how can we differentiate between transferred called in twilio vs outbound calls made using livekit
t
• Call Direction and Transfer Status: ◦ Hey there! When you're working with LiveKit outbound calls, you'll see
call_direction
set to
SCD_OUTBOUND
. Easy peasy! ◦ For transferred calls, you'll notice some extra details like
SIPTransferInfo
with cool fields such as
transfer_id
,
transfer_to
,
transfer_initiated_at_ns
, and
transfer_status
. • SIP Participant Attributes: ◦ Let's talk SIP call IDs!
sip.callID
is LiveKit's way of tagging a conversation, while
sip.callIDFull
is the trunk provider's unique call identifier. • Call Status and Information: ◦ The
SIPCallInfo
structure is like your call's personal ID card – it's got all the details you need, including
call_direction
,
call_status
,
from_uri
,
to_uri
,
trunk_id
, and
dispatch_rule_id
. • Transfer-Specific Detection: ◦ Tracking transfers is a breeze! Look for
SIPTransferInfo
with statuses like
STS_TRANSFER_ONGOING
,
STS_TRANSFER_FAILED
, or
STS_TRANSFER_SUCCESSFUL
. You'll also see handy timing info with
transfer_initiated_at_ns
and
transfer_completed_at_ns
. By putting these methods together, you'll become a pro at telling the difference between LiveKit outbound calls and Twilio transfers. Trust me, it's easier than it sounds! Sources: protobufs/livekit_sip.proto | SIP participant | LiveKit Docs | test/lktest-sip-outbound/README.md