lively-coat-10905
11/04/2025, 3:51 PMInside the agent backend, what’s the officially recommended way to send a JSON message to all room participants?
Is this still valid:
await room.local_participant.publish_data(b"...", topic="agent_text")
Or should we use a method directly on session like session.publish_data(...)?
Goal:
We want to confirm that we’re using the correct, modern way to broadcast agent messages (like full transcripts) to the connected frontend.tall-airline-16756
11/04/2025, 3:51 PMtall-airline-16756
11/04/2025, 3:52 PMawait room.local_participant.publish_data(bytes, topic="agent_text"). This is the documented API for broadcasting data packets to one or more participants. See Data packets.
• There isn’t a documented session.publish_data(...) API for this use case. Agent examples rely on the room/local participant to send text and byte streams. See Sending text and Sending files & bytes.
If helpful, I can share a minimal JSON example (encode/decode) or how to target specific participants instead of broadcasting.
Sources: Data packets | LiveKit docs | Node.js Agents Architecture | livekit/livekit_composite | DeepWiki | Sending text | LiveKit docs | Sending files & bytes | LiveKit docs