c
hi
t
Thanks for reaching out, Arun. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hi — thanks for reaching out! How can I help you today? If you’re reporting an issue, please share a few details so I can assist quickly: • What are you trying to do (join a room, create a session, integrate SDK, etc.)? • Any error messages, screenshots, or logs you’re seeing? • Which SDK/SDK version and environment (web, iOS, Android, server) are you using? • Project ID or Room name (if relevant and safe to share). If you’re just exploring LiveKit and want guidance, tell me what you want to build and I’ll point you to the best next steps. , with interactive elements
c
import { AccessToken, AgentDispatchClient, RoomServiceClient, EncodedFileType, EncodedFileOutput, GCPUpload, RoomCompositeEgressRequest, RoomEgress, RoomConfiguration, RoomAgentDispatch, } from 'livekit-server-sdk'; export class LiveKitService { public static LIVEKIT_URL: string = process.env.LIVEKIT_URL!; public static LIVEKIT_API_KEY: string = process.env.LIVEKIT_API_KEY!; public static LIVEKIT_API_SECRET: string = process.env.LIVEKIT_API_SECRET!; public static client: AgentDispatchClient = new AgentDispatchClient(this.LIVEKIT_URL, this.LIVEKIT_API_KEY, this.LIVEKIT_API_SECRET); public static roomService: RoomServiceClient = new RoomServiceClient(this.LIVEKIT_URL, this.LIVEKIT_API_KEY, this.LIVEKIT_API_SECRET); public static createDispatch(room_name: string, livekit_agent_id: string, metadata: any) { return this.client.createDispatch(room_name, livekit_agent_id, metadata); } public static createToken(room_name: string, participant_name: string) { const token = new AccessToken(this.LIVEKIT_API_KEY, this.LIVEKIT_API_SECRET, { identity: participant_name, name: participant_name, }); token.addGrant({ roomJoin: true, room: room_name, canPublish: true, canSubscribe: true, }); return token.toJwt(); } private static gcpCredentials: string | null = null; private static readonly GCP_BUCKET = 'livkit_call_recordings'; private static getGcpCredentials(): string { if (!this.gcpCredentials) { const credentialsStr = process.env.GCS_CREDENTIALS; if (!credentialsStr) { throw new Error('GCS_CREDENTIALS environment variable is not set'); } try { JSON.parse(credentialsStr); this.gcpCredentials = credentialsStr; } catch (e) { console.error('Invalid JSON in GCS_CREDENTIALS environment variable', e); throw new Error('Invalid JSON in GCS_CREDENTIALS environment variable'); } } return this.gcpCredentials; } public static buildRoomEgress(roomName: string): RoomEgress { const credentials = this.getGcpCredentials(); const fileOutput = new EncodedFileOutput({ fileType: EncodedFileType.OGG, filepath:
${process.env.GCS_FOLDER_NAME}/${roomName}_{time}.ogg
, output: { case: 'gcp', value: new GCPUpload({ credentials, bucket: this.GCP_BUCKET, }), }, }); return new RoomEgress({ room: new RoomCompositeEgressRequest({ audioOnly: true, fileOutputs: [fileOutput], }), }); } public static async createDispatchWithRecording(roomName: string, agentName: string, metadata: string): Promise<void> { const roomConfig = new RoomConfiguration({ agents: [ new RoomAgentDispatch({ agentName, metadata, }), ], egress: this.buildRoomEgress(roomName), }); await this.roomService.createRoom({ name: roomName, egress: roomConfig.egress, agents: roomConfig.agents, }); } } i have a proble here that is isrecosfd satrign vwery uo forn i need ot recor once agetns aastart speaking
t
I don't have the answer you're looking for. You could also try asking your question: • in one of the other Slack channels or • to https://deepwiki.com/livekit/livekit_composite which is trained on all LiveKit source code If you find the answer, please post it here to help others!