Integrations
LiveKit integration (voice / video)
FluxyChat voice features use **LiveKit** as the WebRTC SFU. The Cloudflare Worker issues short-lived JWT access tokens; media runs on your LiveKit server, not o
LiveKit integration (voice / video)
FluxyChat voice features use LiveKit as the WebRTC SFU. The Cloudflare Worker issues short-lived JWT access tokens; media runs on your LiveKit server, not on Workers.
Architecture
Browser (livekit-client) ←WebRTC→ LiveKit SFU
↑ JWT token
FluxyChat Worker (POST /voice/token or dashboard voice-ai routes)- Worker: token minting with
jose(video-voice.js,voice-realtime.tsstubs). - Dashboard:
/voice-aifor agent voice configuration. - Client: add
livekit-clientin React apps; connect with token from Worker.
Self-hosted LiveKit
- Deploy LiveKit server (Docker/K8s).
- Set Worker secrets:
LIVEKIT_API_KEYLIVEKIT_API_SECRETLIVEKIT_URL(wss://your-livekit.example.com)
- Token mint:
POST /admin/calls/tokenusesmintLiveKitAccessTokeninapps/worker/src/lib/livekit-token.js. - Extend client apps with
livekit-clientwhen connecting to the SFU.
React quick start
import { Room, RoomEvent } from "livekit-client";
import { useLiveKitToken } from "@fluxy-chat/react";
function VoiceRoom({ roomId, adminJwt }: { roomId: string; adminJwt: string }) {
const { token, fetchToken } = useLiveKitToken({
workerUrl: process.env.NEXT_PUBLIC_FLUXYCHAT_WORKER_URL!,
adminJwt,
roomId,
displayName: "Alice",
});
async function join() {
const creds = await fetchToken();
if (!creds?.token || !creds.url) return;
const room = new Room();
await room.connect(creds.url, creds.token);
}
return <button type="button" onClick={() => void join()}>Join voice</button>;
}LiveKit Agents (optional)
For AI voice agents, use LiveKit Agents as a separate process. FluxyChat agent runtime can hand off to an agent worker via webhook when a voice session starts.
References
- LiveKit overview
- Access tokens
- Worker stubs:
apps/worker/src/lib/video-voice.js,apps/dashboard/app/voice-ai/