Placeholders
The snippets below use these placeholders. Replace them with your own values before running the code.Prerequisites
- A configured Voice Agent with its agent ID
- An SLNG key (get one at app.slng.ai)
- 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 Voice Agents 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.
Step 1: Create a backend endpoint
Your backend proxies the Voice Agents API so the SLNG key never reaches the browser. The only call you need is:Step 2: Install the LiveKit client SDK
Step 3: Connect to the LiveKit room
Call your backend to get a session, then connect to the room:Step 4: Play the agent’s audio
Attach the agent’s remote audio track to the DOM so the browser plays it:Step 5: Show live transcripts
Transcript updates arrive over a LiveKit data channel on theslng.transcript.v1 topic:
Step 6: Add mute and disconnect controls
Step 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. Adding an animated persona (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:Next steps
- Set up your agent with custom prompts and tools in the Dashboard
- See the Voice Agents API for agent configuration options
- Add phone call support with Telephony
- Add a visual persona with Vercel AI SDK or ElevenLabs UI