proud-monkey-15194
07/05/2025, 4:34 PMtall-airline-16756
07/05/2025, 4:34 PMtall-airline-16756
07/05/2025, 4:35 PMuser_hangup
, agent_hangup
, or user_not picked up
, you can monitor the sip.callStatus
attribute of the SIP participant. This attribute indicates the current call status and can be accessed from the participant's attributes.
The possible values for sip.callStatus
include:
• `active`: Participant is connected and the call is active
• `automation`: For outbound calls using DTMF, indicates the call has connected but is still dialing DTMF numbers
• `dialing`: Call is dialing and waiting to be picked up
• `hangup`: Call has been ended by a participant
• `ringing`: Inbound call is ringing for the caller
Here is an example of how you can monitor the call status:
start_time = perf_counter()
while perf_counter() - start_time < 30:
call_status = participant.attributes.get("sip.callStatus")
if call_status == "active":
<http://logger.info|logger.info>("user has picked up")
return
elif call_status == "automation":
# if DTMF is used in the `sip_call_to` number, typically used to dial
# an extension or enter a PIN.
# during DTMF dialing, the participant will be in the "automation" state
pass
elif call_status == "hangup":
# user hung up, we'll exit the job
<http://logger.info|logger.info>("user hung up, exiting job")
break
await asyncio.sleep(0.1)
This code checks the call status periodically and takes appropriate action based on the status value.
Sources: Making calls using SIP | LiveKit Docs | SIP participant | LiveKit Docs