when doing outbound SIP call, the participant is s...
# ask-ai
m
when doing outbound SIP call, the participant is shown as connected even if they havent picked the call
t
Thanks for reaching out, arijit. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hi there! I wanted to share some helpful info about how SIP participants appear in LiveKit. When the SIP provider accepts the call, the participant shows as connected in the room right away, even if the remote party hasn’t picked up yet. This happens because the participant is added to the room as soon as the trunk provider accepts the INVITE request. To really know if the remote party has answered, you can keep an eye on the
sip.callStatus
attribute for the SIP participant: • `dialing`: The call is in progress but hasn’t been answered yet. • `active`: The remote party has picked up, and audio is flowing between participants. • Sometimes, you might see the status move through
automation
if DTMF tones are being sent during the call. You can easily track these status updates by listening for changes to the
sip.callStatus
attribute using participant events in the LiveKit client SDKs. One more thing to keep in mind—the system waits up to three minutes for the remote party to answer. If the call isn’t picked up within that time, the participant will be disconnected from the room. I hope this helps clarify things, and please feel free to reach out if you have any more questions! Sources: telephony/sip_lifecycle.py | test/lktest/livekit.go | Making outbound calls | LiveKit Docs | SIP participant | LiveKit Docs
m
what event handlers should I listen to get this update in python?
t
To keep track of
sip.callStatus
updates in the Python LiveKit SDK, a great way is to listen for the
participant_attributes_changed
event on the room object. This event fires whenever a participant's attributes change, including any updates to
sip.callStatus
. Here’s a simple example to help you get started:
Copy code
def on_participant_attributes_changed(changed_attributes: dict, participant: rtc.Participant):
    if participant.kind == rtc.ParticipantKind.PARTICIPANT_KIND_SIP and 'sip.callStatus' in changed_attributes:
        new_status = changed_attributes['sip.callStatus']
        print(f"SIP call status updated to: {new_status}")

# Attach the event handler
ctx.room.on("participant_attributes_changed", on_participant_attributes_changed)
Let’s break down what’s happening here: • We first check if the participant is of the
SIP
kind. • Then, we look inside the
changed_attributes
dictionary to see if
sip.callStatus
has changed. • If it has, we handle the status update accordingly. Just so you know, the valid
sip.callStatus
values you might encounter include: • `active`: The call is connected and active. • `automation`: An outbound call is connected and dialing DTMF. • `dialing`: The call is dialing and waiting to be picked up. • `hangup`: The call has ended. • `ringing`: An inbound call is ringing. Sources: telephony/sip_lifecycle.py | SIP participant | LiveKit Docs