salmon-belgium-62133
10/29/2025, 11:24 AMtall-airline-16756
10/29/2025, 11:24 AMtall-airline-16756
10/29/2025, 11:24 AMempty_timeout and max_participants before anyone joins. Then, agents or participants can hop in whenever you're ready.
If you'd like, I’m here to walk you through the setup or answer any questions you have!
Sources: SIP dispatch rule | LiveKit Docs | Core Platform Architecture & Authentication | livekit/livekit_composite | D... | Rooms, participants, and tracks | LiveKit docs | Authentication | LiveKit Docs | Server-Side SDKs & Authentication | livekit/livekit_composite | DeepWikisalmon-belgium-62133
10/29/2025, 11:25 AMtall-airline-16756
10/29/2025, 11:26 AMlk room create my-room
If you prefer, the room will also be created automatically when the very first participant joins, which makes things easy!
2. Generate an Access Token:
To join the room, you’ll need a token that includes the room name, your participant identity, and the right permissions like roomJoin. You can generate these tokens using the server SDKs or the CLI—whichever feels more comfortable for you.
3. Join the Room:
Once you have the WebSocket URL (wsUrl) and your token, you’re ready to connect! For instance, using the CLI, you can do:
lk room join --identity your-identity my-room
Or, if you’re working with a client SDK like Node.js, here’s a quick example:
const room = new Room();
await room.connect(LIVEKIT_URL, token);
If at any point you’d like me to walk you through a specific step or if you have any questions, just let me know—I’m here to help!
Sources: Core Platform Architecture & Authentication | livekit/livekit_composite | D... | README.md | Rooms, participants, and tracks | LiveKit docs | Connecting to LiveKit | LiveKit docs | examples/rpc/index.tssalmon-belgium-62133
10/29/2025, 11:28 AMtall-airline-16756
10/29/2025, 11:29 AMconnect method is called. Here are two friendly ways to do this:
1. Delayed Connection:
You can simply add a delay before calling connect. For example, in JavaScript:
async function entrypoint(ctx) {
// Delay connection by 10 minutes
await new Promise(resolve => setTimeout(resolve, 600000));
await ctx.connect();
}
2. Trigger-Based Connection:
Or, you can wait for a specific event, like a keyboard input, before connecting. Here’s an example:
document.addEventListener('keydown', async (event) => {
if (event.key === 'Enter') { // Trigger on Enter key
await ctx.connect();
}
});
If you’d like, I’m here to help you implement this in your setup—just let me know!
Sources: agents/src/job.ts | livekit-agents/livekit/agents/job.py | README.md | packages/sip--um-actually/README.md | Web and mobile frontends | LiveKit Docssalmon-belgium-62133
10/29/2025, 11:31 AMtall-airline-16756
10/29/2025, 11:31 AMRoomConfiguration. Here's a simple example in Node.js:
import { AccessToken, RoomConfiguration, RoomAgentDispatch } from 'livekit-server-sdk';
const at = new AccessToken();
at.identity = 'my-participant';
at.addGrant({ roomJoin: true, room: 'my-room' });
at.roomConfig = new RoomConfiguration({
agents: [
new RoomAgentDispatch({
agentName: 'test-agent',
metadata: '{"mydata": "myvalue"}',
}),
],
});
const token = await at.toJwt();
2. Explicit Dispatch via Server API:
Alternatively, you can use the Agent Dispatch API to directly tell an agent to join a room. Here’s how you might do it in Node.js:
import { AgentDispatchClient } from 'livekit-server-sdk';
const agentDispatchClient = new AgentDispatchClient(process.env.LIVEKIT_URL);
const dispatch = await agentDispatchClient.createDispatch(
'my-room',
'test-agent',
{ metadata: '{"mydata": "myvalue"}' }
);
console.log('Agent dispatch created:', dispatch);
If you’d like, I’m here to walk you through implementing this or answer any other questions you might have. Just let me know!
Sources: packages/livekit-server-sdk/src/AgentDispatchClient.ts | Authentication | LiveKit Docs | Server-Side SDKs & Authentication | livekit/livekit_composite | DeepWiki | examples/agent_dispatch.pysalmon-belgium-62133
10/29/2025, 11:56 AMtall-airline-16756
10/29/2025, 11:56 AMempty_timeout setting to automatically close the room if no participants join within a set period. Just keep in mind, this applies to any participant, not just agents.
If you'd like to create a more tailored solution that checks specifically for agents, you can monitor the room externally and use the DeleteRoom API to close it programmatically if the agent hasn't joined in time. I’m here to help if you want some guidance on how to set this up—just let me know!
Sources: pkg/rtc/room.go | Authentication | LiveKit Docs | SIP Integration & Telephony | livekit/livekit_composite | DeepWiki | Sources/LiveKit/Types/RoomConfiguration.swift | livekit/livekit_room.pb.gosalmon-belgium-62133
10/29/2025, 12:03 PMtall-airline-16756
10/29/2025, 12:04 PMconst { RoomServiceClient } = require('livekit-server-sdk');
// LiveKit server details
const LIVEKIT_URL = 'your-livekit-server-url';
const API_KEY = 'your-api-key';
const API_SECRET = 'your-api-secret';
// Initialize RoomServiceClient
const roomService = new RoomServiceClient(LIVEKIT_URL, API_KEY, API_SECRET);
// Function to monitor room and close if agent doesn't join
async function monitorRoom(roomName, timeout) {
console.log(`Monitoring room: ${roomName}`);
// Start a timer for the specified timeout
setTimeout(async () => {
try {
// Check if the room still exists
const room = await roomService.getRoom(roomName);
if (room && room.numParticipants === 0) {
console.log(`No agent joined within ${timeout}ms. Closing room: ${roomName}`);
// Close the room
await roomService.deleteRoom(roomName);
console.log(`Room ${roomName} closed.`);
} else {
console.log(`Agent joined the room: ${roomName}. No action needed.`);
}
} catch (error) {
console.error(`Error monitoring room: ${error.message}`);
}
}, timeout);
}
// Example usage
const roomName = 'example-room';
const timeout = 600000; // 10 minutes in milliseconds
monitorRoom(roomName, timeout);
Here’s a quick rundown of what this script does:
• It uses the LiveKit Server SDK to interact with your room.
• Starts a timer as soon as the room is created.
• After the timeout, it checks if anyone has joined.
• If the room is still empty, it closes it by calling deleteRoom.
Just remember to swap out your-livekit-server-url, your-api-key, and your-api-secret with your own LiveKit server details. If you have any questions or want to explore this further, I’m here to help!
Sources: pkg/rtc/room.go | Job lifecycle | LiveKit Docs | Server-Side SDKs & Authentication | livekit/livekit_composite | DeepWiki | hooks/useConnectionTimout.tsx | packages/react/src/hooks/useAgent.tssalmon-belgium-62133
10/29/2025, 12:13 PMtall-airline-16756
10/29/2025, 12:13 PMempty_timeout setting in LiveKit! This feature is designed to automatically close a room if no participants join within the time you specify. It’s a straightforward, built-in option that saves you from having to set up custom monitoring or server-side logic.
If your goal is to close the room after a certain period of inactivity—meaning no participants, including agents, have joined—you can easily configure empty_timeout when creating the room. Here’s an example:
POST /twirp/livekit.RoomService/CreateRoom
{
"name": "example-room",
"empty_timeout": 600 // Time in seconds (10 minutes)
}
Using empty_timeout is a great choice if you want to keep things simple and rely on LiveKit’s built-in functionality. On the other hand, the custom Node.js script can be helpful if you need more advanced control—like checking for specific participants (such as agents) or performing extra actions before closing the room.
Please feel free to reach out if you’d like a hand setting up empty_timeout or if anything needs a bit more clarification. I’m here to help!