I created a room that had some metadata using the ...
# ask-ai
s
I created a room that had some metadata using the Node.JS server sdk:
Copy code
const roomService = new RoomServiceClient(
        process.env.LIVEKIT_URL!,
        process.env.LIVEKIT_API_KEY!,
        process.env.LIVEKIT_API_SECRET!
      );

      const roomOpts: CreateOptions = {
        name: roomName,
        emptyTimeout: 60, //1 minute timeout
        metadata: JSON.stringify(voiceAgentConfig), // pass metadata to configure the agent
      };

      const room = await roomService.createRoom(roomOpts);
the agent joins the room successfully. But I tried to read the room metadata via
_ctx_.room.metadata
in the
entrypoint()
function, and it was not set. Why would this happen?
t
Thanks for reaching out, Shobhit. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hi there! I wanted to share some helpful info about why room metadata might not be set when you try to access it via
ctx.room.metadata
inside the
entrypoint()
function: • First, room metadata needs to be explicitly set when the room is created or updated afterward. So, please double-check that the metadata was correctly included in the
CreateRoom
request or updated using
UpdateRoomMetadata
. • Also, if you're working within an agent implementation, keep in mind that
ctx.room.metadata
becomes available only after the agent successfully connects to the room using
await ctx.connect()
. If you try to access it before the connection, it might not show up yet. If your goal was to pass configuration or initialization data to the agent, these steps are key to verify. And if you’re dealing with job-specific information, a great alternative is to use job metadata, which you can access via
ctx.job.metadata
. I hope this helps clarify things! If you have any more questions or need further assistance, feel free to ask. We're here to support you every step of the way! Sources: Room metadata | LiveKit Docs | Job lifecycle | LiveKit Docs | livekit/livekit_room.pb.go