if I have a scenario where I want multiple concurr...
# ask-ai
v
if I have a scenario where I want multiple concurrent users chatting with a voice agent 1 on 1 (other users are NOT part of the conversation and should not be able to hear or interrupt the conversation) - then should I be creating 1 room per user<>agent conversation or try to do this within 1 room itself? what are the options and what are the tradeoffs involved?
t
Thanks for reaching out, Ruchir. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thank you for sharing your scenario of handling multiple concurrent 1-on-1 user-to-agent voice conversations! LiveKit is quite flexible and supports both of the following approaches: • One room per user-agent conversation: You can use features like SIPDispatchRuleIndividual to create a new room for each caller, with an optional room prefix. This helps keep each conversation nicely separated. • Single room for all conversations: While LiveKit rooms can host multiple participants, managing several isolated 1-on-1 conversations within a single room isn’t explicitly guided, so it might require some extra handling. Both methods have their own benefits depending on what you need. If you’d like, I’m here to help clarify anything or assist you further—just let me know! Sources: SIP dispatch rule | LiveKit Docs | Distributed Setup | LiveKit Docs
v
this user/agent conversation isn't via SIP but via a flutter app
t
When managing multiple 1-on-1 user-agent conversations in your Flutter app, a great approach is to use one room per conversation. This helps to: • Isolation: Keep each conversation private and separate from others. • Scalability: Easily manage rooms independently, including participant lifecycle and permissions. • Security and Privacy: Ensure sensitive interactions stay within their own rooms. • Clear State Management: Allow each Flutter widget or context to bind to a single room without any mix-ups. In your Flutter app, you can create a new
Room
instance for each user-agent pair like this:
Copy code
final room = Room();
await room.connect(url, token, connectOptions: ConnectOptions(autoSubscribe: true));
This approach fits perfectly with LiveKit's design for agent-assisted scenarios. If you have any questions or need a hand with anything else, just let me know—I’m here to help! Sources: Agent-assisted warm transfer | LiveKit Docs | OpenAI Realtime API and LiveKit | LiveKit Docs | packages/rpc-demo/lib/main.dart | lib/src/context/room_context.dart
v
what does this do?
ConnectOptions(autoSubscribe: true)
in the
await room.connect(url, token, connectOptions: ConnectOptions(autoSubscribe: true));
t
I'm happy to explain! The
ConnectOptions(autoSubscribe: true)
in the LiveKit Flutter SDK is designed to make things easier by automatically subscribing your client to all existing and newly published remote tracks (both audio and video) when you connect to a room. What this means is: • As soon as you join, you'll start receiving media streams from everyone else in the room right away. • Any new tracks that get published during your session will be delivered to you automatically, so you won’t miss a thing. Now, if you choose to set
autoSubscribe
to
false
, it does give you the option to manually decide which tracks you want to subscribe to. This can be really helpful if you want more control over your bandwidth and performance. Please feel free to ask if you'd like me to walk you through how to manage that or if you have any other questions! Sources: lib/src/core/room.dart | Rooms, participants, and tracks | LiveKit Docs | Subscribing to tracks | LiveKit Docs
v
once the 1 on 1 conversation with the user and agent is completed - do I need to close/end the room? and if the user wants to have another conversation with the agent, say 20 mins later, then how do I recreate the same room (same name etc) or do I create a net new room?
t
Once you’ve wrapped up a 1-on-1 conversation, here are a couple of friendly options you can choose from: • End the room: You can use the
deleteRoom
API to close the room and gently disconnect everyone. This works best when you’re sure the conversation is fully finished and the room won’t be needed anymore. • Automatic closure: The room will close on its own once the last non-agent participant leaves, which will also disconnect any agents still in the room. When you’re ready for the next conversation, here’s what I recommend: • Create a new room: This is usually the best way to go. Try using a unique room name for each session, like adding a timestamp or a random string (for example,
user_12345_20250724T081259Z
). • Recreate the same room: If you really need to reuse the same room name, just wait about 1–2 minutes after calling
deleteRoom
to make sure the old room is completely cleared out. Using unique room names helps keep each conversation nicely separated and avoids any hiccups with reusing Room IDs. If you have any questions or want a hand with this, I’m here to help! Sources: Anatomy of an Agent | LiveKit Docs | Avoiding Room ID Reuse When Re-Creating Rooms With the Same Name | Inside a session | LiveKit Docs | Inside a session | LiveKit Docs | Job lifecycle | LiveKit Docs