important-judge-78504
10/15/2025, 7:53 PMtall-airline-16756
10/15/2025, 7:53 PMtall-airline-16756
10/15/2025, 7:54 PMdelete_room API. This helps make sure the call ends cleanly for everyone involved, so no one is left in the call hearing silence.
Here’s a quick overview of the steps to follow:
• Use await job_ctx.api.room.delete_room(api.DeleteRoomRequest(room=job_ctx.room.name)) inside your hangup function to delete the room and end the call.
• Set up a shutdown callback by registering ctx.add_shutdown_callback(on_shutdown) to take care of any cleanup when the session finishes.
• To wrap things up smoothly, wait for the current speech to finish playing out with await current_speech.wait_for_playout() before hanging up.
If you’d like, I’m here to help with any part of the implementation or answer any questions you might have. Just let me know!
Sources: Agents telephony integration | LiveKit Docs | agent.py | complex-agents/drive-thru/frontend/components/livekit/agent-control-bar/age... | Operational Guidance & Best Practices | livekit/livekit_composite | DeepWik... | How to detect and handle silence during callsimportant-judge-78504
10/15/2025, 7:55 PMtall-airline-16756
10/15/2025, 7:56 PMctx.shutdown()? For instance, is it related to a JobContext, AgentSession, or something else? Knowing this will really help me guide you better.
Sources: Job lifecycle | LiveKit Docs | How to detect and handle silence during calls | Agents telephony integration | LiveKit Docs | livekit-agents/livekit/agents/voice/agent_session.pyimportant-judge-78504
10/15/2025, 8:05 PMtall-airline-16756
10/15/2025, 8:06 PMctx.remote_participants list. It doesn’t keep information on participants who have disconnected. So, when someone leaves, they’re removed from the remote_participants collection.
This is actually how it works across all LiveKit SDKs — disconnected participants are taken out of the list to make sure it always shows only those who are currently connected. I hope this helps clarify things for you!
Sources: src/room/Room.ts | stream_audio.py | livekit/src/room/mod.rsimportant-judge-78504
10/15/2025, 8:07 PMtall-airline-16756
10/15/2025, 8:08 PMtwilio_call_sid for a participant, you can easily access it through the participant's attributes when using Twilio SIP trunks. LiveKit thoughtfully includes Twilio-specific attributes like sip.twilio.callSid in the participant's attributes field whenever a call is made via a Twilio SIP trunk.
Here’s a simple way to get it:
• Check Participant Attributes: Take a look at the attributes field of the participant object. If the call is routed through Twilio, you’ll find the sip.twilio.callSid attribute there.
• Use Server SDKs or APIs: You can also retrieve this value programmatically by listing participants in a room or by listening to participant events like participant_joined, then accessing their attributes.
• Ensure Proper Trunk Configuration: Just a quick note—the sip.twilio.callSid attribute will only be available if you’re using a Twilio SIP trunk and have set it up to forward SIP headers that LiveKit maps into these attributes.
If you’d like, I’m here to help with any further questions or even provide examples to make implementation smoother for you. Just let me know!
Sources: SIP participant | LiveKit Docs | pkg/sip/participant.goimportant-judge-78504
10/15/2025, 8:14 PMtall-airline-16756
10/15/2025, 8:16 PMtwilio_call_sid for all participants, including those who have disconnected, a great approach is to capture it right when participant events happen, like participant_joined or participant_disconnected. When using Twilio SIP trunks, you’ll find the sip.twilio.callSid attribute included in the participant’s attributes.
Here are some friendly options you can consider:
• Capture During Events: Keep an eye on the participant_joined or participant_disconnected events to grab and save the twilio_call_sid for each participant as they come and go.
• Server-Side Retrieval: You can also use LiveKit’s server SDKs to list participants in a room and access their attributes, including the sip.twilio.callSid. This method works well for participants who are still connected.
• Webhook Handlers: Setting up webhook handlers to catch participant events is another solid way to store the twilio_call_sid in your database, so you have it handy even after participants disconnect.
Using the participant_joined event is a really reliable way to make sure you capture the twilio_call_sid for everyone. Pairing this with server-side storage or webhooks can give you an even stronger setup for keeping track of disconnected participants. If you’d like, I’m here to help with more details or examples to get you started!
Sources: SIP participant | LiveKit Docs | stream_audio.py | livekit/src/room/mod.rs | livekit-protocol/livekit/protocol/sip.pyi | test/lktest/livekit.goimportant-judge-78504
10/15/2025, 8:21 PMtall-airline-16756
10/15/2025, 8:22 PMimportant-judge-78504
10/15/2025, 8:22 PMtall-airline-16756
10/15/2025, 8:23 PM