enough-match-43171
12/15/2025, 2:43 PMtall-airline-16756
12/15/2025, 2:43 PMtall-airline-16756
12/15/2025, 2:43 PMagent_name when declaring the agent session:
server = AgentServer()
@server.rtc_session(agent_name="my-telephony-agent")
async def my_agent(ctx: JobContext):
...
For Node.js
1. Set agentName in `WorkerOptions`:
const opts = new WorkerOptions({
agentName: "my-telephony-agent",
});
Notes
• Setting an agent name enables explicit agent dispatch and disables automatic dispatch; the agent will be assigned to rooms only when explicitly dispatched.
• You can dispatch named agents via the CLI, for example:
lk dispatch create --agent-name my-telephony-agent --new-room
Would you like the exact code snippet inserted into your existing agent file or help dispatching the agent to a room?
Sources: Agents telephony integration | LiveKit docs | Agent dispatch | LiveKit docsenough-match-43171
12/15/2025, 2:44 PMtall-airline-16756
12/15/2025, 2:45 PMagent_name (Python or Node client).
• Include the agent name in room configuration when minting an access token (RoomAgentDispatch.agent_name) so the room requests that specific agent.
• Call the CLI with --agent-name when creating a dispatch.
Notes to keep in mind:
• Setting an explicit agent_name on an agent disables automatic dispatch; the agent will only be assigned when explicitly dispatched.
• Changing agent names after deployment can affect dispatch rules and frontends, so plan changes carefully.
• You can run multiple workers with the same agent_name for load balancing/high availability.
Would you like an example for Python or Node that fits into your current code or help wiring dynamic names from your backend (e.g., based on user or metadata)?
Sources: Agent dispatch | LiveKit docs | Agent Builder | LiveKit docs | Agents Framework | livekit/livekit_composite | DeepWikienough-match-43171
12/15/2025, 3:31 PMtall-airline-16756
12/15/2025, 3:31 PMRoom constructor.
What you can do:
• Set metadata server-side when creating the room with the RoomService API:
const room = await roomService.createRoom({
name: 'my-room',
metadata: JSON.stringify({ purpose: 'meeting', host: 'user123' }),
});
• Update metadata later from the server:
await roomService.updateRoomMetadata('my-room', JSON.stringify({ status: 'active' }));
• On the client, listen for updates:
room.on('metadataChanged', (newMeta: string) => {
console.log('Room metadata:', newMeta);
});
Would you like a ready-to-use server example (Node or Python) that fits your backend?
Sources: Room metadata | LiveKit docsenough-match-43171
12/15/2025, 3:32 PMtall-airline-16756
12/15/2025, 3:32 PMroom.on('Disconnected', () => {
console.log('Disconnected from room');
// cleanup UI, stop timers, notify user, etc.
});
Swift (iOS/macOS)
room.on(.disconnected) {
print("Disconnected from room")
// cleanup or UI updates
}
Kotlin (Android)
room.addConnectionListener(object : RoomConnectionListener {
override fun onDisconnected() {
println("Disconnected from room")
// cleanup or UI updates
}
})
Flutter / Dart
room.on<RoomDisconnectedEvent>((event) {
print("Disconnected from room");
// cleanup or UI updates
});
Would you like a brief example that shows cleanup steps (reconnect UI, state reset) for your specific app?
Sources: Handling events | LiveKit docs | Connecting to LiveKit | LiveKit docsenough-match-43171
12/15/2025, 3:33 PMtall-airline-16756
12/15/2025, 3:33 PMconnect and receives a Room object you can listen on.
Example flow (server + client):
1) Server: create room & mint token (room created via RoomService)
• Create or ensure room exists, then generate an access token scoped to that room and participant identity. Return the token (JWT) to the client.
2) Client: connect with the token and get the Room instance
import { Room } from 'livekit-client';
// token received from your backend
const token = '<TOKEN_FROM_SERVER>';
const room = new Room({
adaptiveStream: true,
dynacast: true,
videoCaptureDefaults: { resolution: { width: 1280, height: 720, frameRate: 30 } },
});
// connect and obtain the Room instance to listen for events
await room.connect('<wss://your-livekit-url>', token);
// now you can listen for disconnect and other events
room.on('Disconnected', () => {
console.log('Disconnected from room');
});
If you already create the room server-side, just ensure your server returns the join token (and room name if needed) to the client. The client uses that token in room.connect(...) to obtain the Room object for event handling.
Do you want a snippet showing how to mint the token on Node or Python?