> Inside the agent backend, what’s the official...
# ask-ai
l
Inside the agent backend, what’s the officially recommended way to send a JSON message to all room participants?
Is this still valid:
Copy code
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.
t
Thanks for reaching out, Computer. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Regarding how to broadcast JSON to all room participants from your agent backend: • The recommended approach is to use the room’s local participant:
await 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