delightful-hospital-74104
05/12/2025, 10:55 PMtall-airline-16756
05/12/2025, 10:55 PMtall-airline-16756
05/12/2025, 10:55 PMEnded
event on the Track object. When a SIP participant's call ends, the track associated with that participant will trigger the Ended
event. You can subscribe to this event using:
track.Ended += OnTrackEnded;
Here, OnTrackEnded
is your event handler method, which you can define as:
void OnTrackEnded(Track track)
{
// Your code to handle the ended call
}
Additionally, you can monitor the SIP participant's attributes, specifically the sip.callStatus
attribute, which will change to hangup
when a call has been ended by a participant.
Sources: SIP participant | LiveKit Docs | Class Track | LiveKit Unity SDK | Delegate ITrack.EndedDelegate | LiveKit Unity SDKdelightful-hospital-74104
05/12/2025, 10:56 PMdelightful-hospital-74104
05/12/2025, 10:57 PMtall-airline-16756
05/12/2025, 10:57 PMsip.callStatus
from a Python agent, you can use the following approach:
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)
<http://logger.info|logger.info>("Session timed out, exiting job")
ctx.shutdown()
The sip.callStatus
attribute can have the following values:
• `active`: Indicates the user has answered the call
• `automation`: Indicates DTMF dialing is in progress (for entering extensions or PINs)
• `hangup`: Indicates the user has hung up
This loop checks the status every 0.1 seconds for up to 30 seconds before timing out.
Sources: Making calls using SIP | LiveKit Docstall-airline-16756
05/13/2025, 12:07 AMsip.callStatus
from a Python agent, you can use the following approach:
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)
<http://logger.info|logger.info>("Session timed out, exiting job")
ctx.shutdown()
The sip.callStatus
attribute can have the following values:
• `active`: Indicates the user has answered the call
• `automation`: Indicates DTMF dialing is in progress (for entering extensions or PINs)
• `hangup`: Indicates the user has hung up
This loop checks the status every 0.1 seconds for up to 30 seconds before timing out.