billowy-psychiatrist-32507
09/03/2025, 8:17 AMtall-airline-16756
09/03/2025, 8:17 AMtall-airline-16756
09/03/2025, 8:19 AMawait ctx.room.local_participant.perform_rpc(
destination_identity=client_participant.identity,
method="receive_recommendations",
payload=json.dumps({"recommendations": recommended_products})
)
Frontend Implementation:
localParticipant.registerRpcMethod(
'receive_recommendations',
async (data) => {
const payload = JSON.parse(data.payload);
console.log('Received recommendations:', payload.recommendations);
// Use the data in your frontend as needed
}
);
This way, your recommended products get sent in real-time and your frontend can use them right away. If you have any questions or want to chat more about it, just let me know—I’m here to help!
Sources: complex-agents/nova-sonic/form_agent.py | Tool definition and use | LiveKit Docs | Function calling with Voice Agents | LiveKit Docs | agent-console/app/api/room/send-data/route.ts | Data packets | LiveKit Docsbillowy-psychiatrist-32507
09/04/2025, 3:41 AMtall-airline-16756
09/04/2025, 3:41 AMpublish_data from the backend and DataReceived on the frontend as an alternative to RPC. Just a heads-up, there are some important differences between these two:
RPC (Remote Procedure Call):
• This lets you call a specific method on another participant and get a response back.
• Great for structured, request-response interactions—like triggering actions or fetching specific data.
• It’s actually built on top of the publish_data system but offers a more polished way to handle complex interactions.
publish_data:
• This is a more basic API for sending data packets to one or more participants in a room.
• It doesn’t expect a response—it’s more like broadcasting a message.
• You can choose reliable (in-order delivery) or lossy (faster but no delivery guarantee) transmission.
• Plus, you can send data to specific participants or the whole room using the destination_identities parameter.
So, in a nutshell: go with publish_data if you just need simple, one-way data sending. If you want a neat request-response setup, RPC is your friend. If you want, I’m here to help you get started with either one!
Sources: packages/livekit-rtc/README.md | Data packets | LiveKit Docs | livekit/src/room/participant/local_participant.rs