Hi, can someone help me in dispatching AI agent(de...
# server-api
h
Hi, can someone help me in dispatching AI agent(deployed on livekit cloud) to a meeting room while craeting access token. I am also trying to use aut-egress feature in meeting room. Everytime it picks self-hosted agent. Here is the code i am currently I am using : // Helper function to create a participant token function createParticipantToken(userInfo: AccessTokenOptions, roomName: string) { // 1) Ensure room exists with auto-egress const svc = new RoomServiceClient(LIVEKIT_URL!, API_KEY!, API_SECRET!); try { const room = svc.createRoom({ name: roomName, egress: new RoomEgress({ tracks: { filepath: "flo-ai-interviewer/{room_name}-{publisher_identity}-{time}", output: { case : "s3", value : { accessKey: process.env.S3_VIDEO_UPLOAD_ACCESS_KEY!, secret: process.env.S3_VIDEO_UPLOAD_SECRET!, bucket: "flo-ai-interviewer", region: "ap-south-1", }} } }), // (optional) dispatch your agent now instead of via token //agents: [ {agentName: "flo-ai-test", metadata: '{"user_id": "CA_RVPYRf6ayiPU"}',}], }); console.log(
Created room
); } catch (err: any) { // If room already exists, ignore; otherwise rethrow if (!String(err?.message || "").toLowerCase().includes("already exists")) throw err; } //const dispatch = new AgentDispatchClient(LIVEKIT_URL!, API_KEY!, API_SECRET!); //dispatch.createDispatch(roomName, "flo-ai-test"); const at = new AccessToken(API_KEY!, API_SECRET!, userInfo); const grant: VideoGrant = { room: roomName, roomJoin: true, canPublish: true, canPublishData: true, canSubscribe: true, }; at.addGrant(grant); at.roomConfig = new RoomConfiguration({ agents: [ new RoomAgentDispatch({ agentName: "flo-ai-test", metadata: '{"user_id": "CA_RVPYRf6ayiPU"}', }), ], }); return at.toJwt(); }
r