How to get call data like call duration, call stat...
# ask-ai
f
How to get call data like call duration, call status, call started at, call ended at
t
Thanks for reaching out, Ayush. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
I'm happy to help you retrieve call data such as call duration, status, and timestamps (started at, ended at) in LiveKit. Here are some methods you can use: • Call Status: You can use the
sip.callStatus
participant attribute to keep an eye on the real-time state of the call. The statuses you might see include dialing, ringing, active, automation, and hangup. • Call Started At / Ended At: These timestamps are available in the
started_at_ns
and
ended_at_ns
fields within the
SIPCallInfo
object. They represent the time in nanoseconds since the Unix epoch. • Call Duration: You can find the duration by simply subtracting
started_at_ns
from
ended_at_ns
. If you want to access this data programmatically, setting up webhooks to receive analytics events like
SIP_CALL_STARTED
and
SIP_CALL_ENDED
is a great approach. These events will include the
SIPCallInfo
object with all the details you need. Please feel free to reach out if you'd like any help with setting up those webhooks or if you have any other questions. I'm here to support you! Sources: SIP & Telephony Integration | livekit/livekit_composite | DeepWiki | livekit/livekit_analytics.pb.go | livekit-protocol/src/livekit.rs | livekit-protocol/livekit/protocol/analytics.py | Making calls using SIP | LiveKit Docs