This question originally came up in our Slack community and the thread has been consolidated here for long-term reference.
How can I send a website URL from my Python LiveKit agent to my React frontend so that React can automatically navigate the user to that website?
When the AI agent decides on a website (e.g., https://example.com), I want to send that URL to the React app, and then React should navigate to that page.
Use RPC (Remote Procedure Calls) to send messages between your agent and frontend:
-
Send a message from your agent to the front end over RPC: RPC is a generic messaging system with no specific message format. Send the URL over RPC.
Remote method calls | LiveKit Documentation
-
Handle the message in React: When you receive the RPC message, use your navigation mechanism (e.g., React Router) to navigate to the desired page.
See the drive-thru example which uses RPC to update the frontend with data: