how to know the ring duration when a call was plac...
# ask-ai
b
how to know the ring duration when a call was placed?
t
Thanks for reaching out, Utkarsh. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — I’m responding to your question about how to determine the ring duration when a call was placed. You can measure ring duration in two practical ways: by listening to SIP participant attribute changes programmatically, or by inspecting call timelines in Agent Observability. Both rely on tracking when the call enters the
ringing
state and when it transitions to
active
(answered) or
hangup
(not answered). Recommended approach (programmatic — best for automated tracking) 1. Listen for
participant_attributes_changed
events for the SIP participant. 2. When
sip.callStatus
changes to
ringing
, record a timestamp (start). 3. When
sip.callStatus
changes to
active
or
hangup
, record a second timestamp (end). 4. Ring duration = end − start. Example logic (pseudocode): • on `participant_attributes_changed`: ◦ if participant is SIP and
sip.callStatus
changed: ▪︎ if `ringing`: store
ring_start_time
▪︎ if
active
or `hangup`: compute
time.now() - ring_start_time
and log/store the result What to log/save •
sip.callStatus
transitions and their timestamps • identifiers like
sip.phoneNumber
or
sip.trunkID
so you can correlate the duration to a specific call • whether the final state was
active
(answered) or
hangup
(not answered) Alternative/manual approach (Agent Observability) • Use the LiveKit Cloud Dashboard’s Agent Insights timeline and logs. • Inspect the timeline or trace events to find when
ringing
began and when
active
or
hangup
occurred; subtract those timestamps to get ring duration. • This is useful for post-call analysis and troubleshooting. If you’d like, I can: • Provide a concrete code example in your preferred language (JavaScript, Python, or TypeScript). • Suggest a data model for storing these timestamps in your database. • Help with specific event names or attribute paths if you share which SDK or integration you’re using. Which option do you prefer, and what language/SDK are you using? Sources: SIP Lifecycle Management Agent | LiveKit Documentation | Streamline troubleshooting with Agent Observability | Outbound Calling Script | LiveKit Documentation