i want to publish some custom events like tool cal...
# ask-ai
r
i want to publish some custom events like tool calls from the voice agent to the frontend. what is the best way to do this?
✅ 1
t
Thanks for reaching out, Taresh. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — regarding publishing tool-call events from a voice agent to the frontend: the recommended approach is to forward them via RPC. How to do it 1. Agent side: call
room.local_participant.perform_rpc()
with the tool/event payload when the tool runs. 2. Frontend: register an RPC handler with
localParticipant.registerRpcMethod()
to receive the payload and update UI or trigger client actions. Why RPC • Designed for agent→frontend function calls and structured data delivery. • Works well for tool calls that should trigger immediate UI behavior. If you want alternatives or implementation examples, do you prefer a short code snippet for the agent (JS/TS or Python) or the frontend (web SDK)? Sources: Forwarding to the frontend | LiveKit Documentation | Creating and Publishing Custom Metrics, with interactive elements