How do i get twilio call sid if I am doing SIP lik...
# ask-ai
n
How do i get twilio call sid if I am doing SIP like this:
Copy code
await self.ctx.api.sip.create_sip_participant(
                api.CreateSIPParticipantRequest(
                    room_name=self.ctx.room.name,
                    sip_trunk_id=outbound_trunk_id,
                    sip_call_to=phone_number,
                    participant_identity=user_identity,
                )
            )
t
Thanks for reaching out, Nikhil. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hey there! Just a quick heads-up: when you use the
CreateSIPParticipantRequest
method, the Twilio Call SID doesn’t pop up right away. Instead, it shows up as a participant attribute once the SIP participant has joined and connected to the room. Here’s a simple way to grab that Twilio Call SID: 1. Create the SIP participant with
CreateSIPParticipantRequest
. 2. Wait for them to actually join the room. 3. Then, check out the participant’s attributes to find the Twilio Call SID under the key
sip.twilio.callSid
. To make it clearer, here’s a quick example in Python:
Copy code
from livekit import rtc

# Check if the participant is a SIP participant
if participant.kind == rtc.ParticipantKind.PARTICIPANT_KIND_SIP:
    twilio_call_sid = participant.attributes.get('sip.twilio.callSid')
    print(f"Twilio Call SID: {twilio_call_sid}")
If you have any questions or want me to walk you through it, just let me know—I’m here to help! Sources: SIP participant | LiveKit Docs | SIP participant | LiveKit Docs | pkg/service/sip.go