how do i start a room wihtout a human participant ...
# ask-ai
g
how do i start a room wihtout a human participant adding
t
Thanks for reaching out, Dhruv. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hey there! If you want to start a room in LiveKit without a human participant, here are some friendly ways to do it: • Create Room via Server API: You can easily create an empty room using the RoomServiceClient. Here’s a quick example in Go:
Copy code
room, _ := 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:
Copy code
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:
Copy code
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:
Copy code
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:
Copy code
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 Agents
g
how do i dispatch an agen and make it join an empty room
t
Hey there! If you want to dispatch an agent and have it join an empty room in LiveKit, here’s a friendly guide to help you out: • Explicit Agent Dispatch via API: You can use the
AgentDispatchClient
to send an agent to a specific room. Here’s a quick example in Node.js:
Copy code
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:
Copy code
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