Prerequisites
- A configured agent and its agent ID. If you do not have one, see Create an agent.
- An SLNG API key. See How to set up.
- A backend you can deploy server-side code to (Node.js, Deno, Python, etc.)
- A frontend project with React (the examples below use React, but the LiveKit client SDK works with any framework)
How it works
- The browser asks your backend to start a session.
- Your backend calls the SLNG web-sessions endpoint and forwards the LiveKit credentials back.
- The browser connects to the LiveKit room, publishes the mic, and plays the agent’s audio.
Build the integration
1
Create a backend endpoint
Your backend proxies the SLNG API so the API key never reaches the browser.The only call you need is:The response includes the fields you need for the frontend:
Never call the SLNG API directly from client-side code. Your
SLNG_API_KEY
must stay server-side.Response
2
Install the LiveKit client SDK
livekit-client is LiveKit’s browser SDK. It opens the WebRTC connection to the room, publishes your microphone, subscribes to the agent’s audio, and delivers transcripts over a data channel. It ships TypeScript types and runs in any framework or in plain JavaScript.The SDK needs a secure context, so serve your page over HTTPS or
localhost for the browser to allow microphone capture and WebRTC. For the full API, see the LiveKit JS client reference.3
Connect to the LiveKit room
Call your backend to get a session, then connect to the room:
4
Play the agent's audio
Attach the agent’s remote audio track to the DOM so the browser plays it:
5
Show live transcripts
Transcript updates arrive over a LiveKit data channel on the Each transcript item has:
slng.transcript.v1 topic:6
Add mute and disconnect controls
7
Detect who is speaking
The active-speakers event tells you when the agent is talking, so you can drive a visual indicator or avatar animation:
Optional: Add a visual persona
A voice-only interface gives users no visual cue about what the agent is doing. An animated persona such as an orb, waveform, or avatar makes the experience feel more responsive. Two ready-made libraries work well here:Vercel AI SDK Persona
A React component with built-in states:
idle, listening, speaking, thinking. Drop it in and map LiveKit events to states.ElevenLabs Conversational UI
Orb and avatar components designed for voice interfaces, with audio-reactive animations.
Putting it all together
A minimal React component with all the steps above wired together:VoiceSession.tsx
Next steps
- Configure your agent’s prompt and tools in Create an agent.
- Add phone call support with Telephony.
- Watch your sessions in Observability and usage.
- Add a visual persona with Vercel AI SDK or ElevenLabs UI.