Thanks — since an agent stays connected and you want a delayed timeout, here's a simple, reliable pattern you can implement.
1) Listen for the participant-left webhook/event (detect last non-agent human leaving). 2) When that event occurs, start a timer for your desired delay (e.g., 5–30 minutes). 3) On timer expiry, verify room state:
• Confirm only agents/ingress/egress remain (no human participants).
• Confirm no active egress/ingress workflows you need to keep.
4) If checks pass, call the DeleteRoom API to destroy the room immediately. 5) Optional: cancel the timer if a human rejoins before expiry.
Implementation notes:
• Persist the timer state (in-memory will work for single-instance apps; use Redis or a DB for multi-instance resilience).
• Log the delete attempt and failures; retry a few times if DeleteRoom fails.
• Use unique per-session room names (timestamp/UUID) if you want strict one-session lifecycles.
Would you like a short code example for starting the timer from a webhook handler and calling DeleteRoom in your preferred language?