alert-alarm-99875
11/25/2025, 9:38 AMtall-airline-16756
11/25/2025, 9:38 AMtall-airline-16756
11/25/2025, 9:38 AMsendText() for a simple URL, or RPC if you want an explicit "navigate" call).
Sources: AI Agents Framework | livekit/livekit_composite | DeepWiki | Sending text | LiveKit docs | Data packets | LiveKit docs | Remote method calls | LiveKit docs | Sending files & bytes | LiveKit docsalert-alarm-99875
11/25/2025, 9:45 AMtall-airline-16756
11/25/2025, 9:46 AMsendText()) approach. It's simple and reliable.
1) Python agent — send the URL once:
# send a navigation message (topic is optional but useful to filter)
await room.local_participant.send_text("https://example.com", topic="navigation")
2) Next.js (browser JS) — listen for data and navigate:
import { useEffect } from "react";
import { RoomEvent } from "livekit-client";
export default function useAgentNavigation(room) {
useEffect(() => {
if (!room) return;
const handler = (data: Uint8Array, participant, kind) => {
// only handle navigation topic messages
if (kind !== undefined && kind !== "reliable") return;
const decoder = new TextDecoder();
const url = decoder.decode(data);
// optional: check topic via participant/data metadata if you emit it,
// or validate URL before navigating
if (url && url.startsWith("http")) {
window.location.href = url;
}
};
room.on(RoomEvent.DataReceived, handler);
return () => {
room.off(RoomEvent.DataReceived, handler);
};
}, [room]);
}
Notes and small checks:
• Use the topic="navigation" on send to help filter messages. If your SDK exposes topic metadata differently, confirm you can read it — otherwise validate the string contents before navigating.
• Validate the URL (startsWith http/https) to avoid unsafe redirects.
• This triggers a full-page navigation via window.location.href. If you prefer client-side routing in Next.js, replace with your router (e.g., router.push(url)) after ensuring the URL is internal.
If you want, I can provide the exact Next.js example using next/router instead of window.location, or an RPC-based example so the frontend explicitly accepts navigation calls. Which would you prefer?