gorgeous-soccer-57984
08/25/2025, 9:10 AMtall-airline-16756
08/25/2025, 9:10 AMtall-airline-16756
08/25/2025, 9:11 AMroom, _ := roomClient.CreateRoom(context.Background(), &livekit.CreateRoomRequest{
Name: "myroom",
EmptyTimeout: 10 * 60, // 10 minutes
MaxParticipants: 20,
})
• Use AI Agents: You can start a VoicePipelineAgent in the room. These agents act like participants and help keep the room alive:
agent.start(room, participant); // participant can be null
• Configure Room Timeouts: Adjust the empty_timeout and departure_timeout settings to keep the room open even when no one’s in it for a little while:
room:
empty_timeout: 300 # 5 minutes
departure_timeout: 20 # 20 seconds
• Simulated Participants: For testing purposes, you can fill a room with fake participants to see how it behaves:
await room.simulateParticipants({
participants: {
count: 9,
audio: false,
video: true,
}
});
• Use CLI for Testing: You can also join a room and publish some demo content using the LiveKit CLI like this:
lk room join --url ws://localhost:7880 --api-key devkey --api-secret secret --publish-demo --identity bot_user my_first_room
Honestly, the easiest and most practical way for production is to create the room via the server API and have an AI agent join first to keep things running smoothly. Hope this helps you get started!
Sources: src/room/Room.ts | LiveKit CLI | livekit/livekit_composite | DeepWiki | Rooms, participants, and tracks | LiveKit Docs | Managing rooms | LiveKit Docs | VoicePipelineAgent | LiveKit Agentsgorgeous-soccer-57984
08/25/2025, 9:14 AMtall-airline-16756
08/25/2025, 9:15 AMAgentDispatchClient to send an agent to a specific room. Here’s a quick example in Node.js:
import { AgentDispatchClient } from 'livekit-server-sdk';
const agentDispatchClient = new AgentDispatchClient(process.env.LIVEKIT_URL);
// Dispatch an agent to join 'my-room'
const dispatch = await agentDispatchClient.createDispatch('my-room', 'test-agent', {
metadata: '{"mydata": "myvalue"}',
});
• Dispatch via Access Token Configuration: Another way is to set up a participant’s token so agents get dispatched right when they connect. Here’s how you can do that in Node.js:
import { AccessToken } from 'livekit-server-sdk';
const at = new AccessToken();
at.identity = 'my-participant';
at.addGrant({ roomJoin: true, room: 'my-room' });
at.roomConfig = {
agents: [
{ agentName: 'test-agent', metadata: '{"mydata": "myvalue"}' },
],
};
const token = await at.toJwt();
• Automatic Agent Dispatch: By default, LiveKit automatically dispatches agents when rooms get created. So, if someone connects and the room isn’t there yet, it’ll be created on the spot and an agent will be assigned.
Using explicit dispatch via the API gives you the most control, but automatic dispatch is super handy if you want things to just work smoothly every time. If you have any questions or want to chat more about this, just let me know—I’m here to help!
Sources: Dispatching agents | LiveKit Docs | packages/livekit-server-sdk/src/AgentDispatchClient.ts | livekit-api/livekit/api/agent_dispatch_service.py