how to determine in agent session that the call wa...
# ask-ai
f
how to determine in agent session that the call wasn't picked up?
t
Thanks for reaching out, Taras. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
To help you figure out if a call wasn’t picked up during an agent session, you’ll want to keep an eye on the
sip.callStatus
participant attribute. If a call moves straight from
dialing
(for outbound) or
ringing
(for inbound) to
hangup
without ever becoming
active
, that’s a sign it wasn’t answered. In your agent code, you can listen for changes in
sip.callStatus
by using the
on("participant_attributes_changed")
event. Here’s a little example to guide you:
Copy code
def on_participant_attributes_changed_handler(changed_attributes: dict, participant: rtc.Participant):
    if participant.kind == rtc.ParticipantKind.PARTICIPANT_KIND_SIP:
        if 'sip.callStatus' in changed_attributes:
            call_status = changed_attributes['sip.callStatus']
            if call_status == 'hangup':
                print("Call was not picked up.")
Also, for outbound calls, you might find it helpful to use
wait_until_answered=True
in the
create_sip_participant
method. This way, the call will pause until it’s either answered or fails. If it’s not answered, an error will be raised that you can catch and handle in your code. If you’d like, I’m here to help you through the implementation or answer any other questions you might have! Sources: SIP participant | LiveKit Docs | telephony/sip_lifecycle.py | agent.py | How to detect and handle silence during calls | pkg/sip/participant.go