when making an outbound call via create_sip_partic...
# ask-ai
i
when making an outbound call via create_sip_participant i've noticed that a participant connected event will fire, even if the sip code returned is not a 200 (in which case a participant disconnected event fires). what exactly fires a participant connected event?
t
Thanks for reaching out, Ed. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
I'm glad you're interested in understanding the
participant_connected
event! This event happens when the SIP participant has been successfully added to the LiveKit room you specified. It takes place right after the SIP trunk provider accepts the call and the participant joins the room. To break it down a bit: • Once you call
create_sip_participant
, LiveKit reaches out by sending an INVITE request to the SIP trunk provider. • If the call is accepted, LiveKit then adds the SIP participant to the room, which triggers the
participant_connected
event. One important thing to keep in mind is that this event means the SIP participant has joined the room, even if the actual phone call hasn’t been answered yet. To be sure the call is answered, you can keep an eye on the
sip.callStatus
participant attribute—it changes to
active
once the remote party picks up the call. Sources: Making outbound calls | LiveKit Docs | Docs::Telephony | Docs::Telephony
i
gotcha so even if the sip code comes back as a 480 (which means we didnt get through) a "participant" can still be connected? is there any ground truth that i can use to see if a call actually succeeded to get through?
t
I understand this can be a bit confusing, so let me help clarify! Even if the SIP code returns a 480, which usually means the call didn’t get through, a "participant" might still be connected to the room. To really know if a call was successful, it’s best to check the
sip.callStatus
participant attribute—it’s like your go-to source for the true status. Here’s what the
sip.callStatus
attribute tells you: • dialing: The call is just starting to set up • ringing: The call is ringing on the other end • automation: The call is connected but still dialing DTMF numbers (for outbound calls) • active: The call has been successfully connected • hangup: The call has ended When the
sip.callStatus
changes to active, that’s your sign the call was answered and is successful. You can keep an eye on this attribute programmatically to confirm everything went smoothly. Also, while SIP status codes like 200 (OK) or 202 (Accepted) at the protocol level can indicate success, the
sip.callStatus
within LiveKit is really the most trustworthy way to know what’s happening. Sources: SIP & Telephony Applications | livekit/livekit_composite | DeepWiki | protobufs/livekit_sip.proto | Making outbound calls | LiveKit Docs | Docs::Telephony | Docs::Telephony
i
ok when does a participants attributes change to "active"?
t
When a SIP participant’s attributes change to
active
, it means the call is fully connected and audio is flowing smoothly. The exact moment this happens depends on the type of call: • Inbound calls: The
sip.callStatus
switches to
active
once the SIP participant subscribes to any remote audio tracks. • Outbound calls: The status updates to
active
when the callee answers the call. • Outbound calls with DTMF: Initially, the status will be
automation
while dialing DTMF numbers, and then it changes to
active
after the dialing finishes. To keep track of this change, you can listen for the
participant_attributes_changed
event. This event will let you know exactly when the
sip.callStatus
moves to
active
. If you have any questions about this or need further help, feel free to ask—I’m here to support you! Sources: livekit-rtc/livekit/rtc/room.py | livekit-android-sdk/src/main/java/io/livekit/android/events/RoomEvent.kt | Docs::Telephony | SIP participant | LiveKit Docs | Make outbound calls | LiveKit Docs