how could i use livekit to connect a client to a c...
# ask-ai
n
how could i use livekit to connect a client to a customer support specialist but also have an agent listening to the conversation, transcribing it and showing potential answers to the customer support specialist based on the client input?
t
Thanks for reaching out, Karl. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
You can do this with LiveKit by having three participants in the same room: the client, the support specialist (agent), and an AI listener (copilot) that subscribes to audio, transcribes speech, runs an LLM, and sends suggestions to the specialist via data messages. Below is a focused implementation plan and minimal examples to get you started. Summary of the flow 1. Client + specialist join the same LiveKit room and publish their audio. 2. AI listener joins the same room but does not publish audio (subscribe-only). 3. Listener receives audio streams, uses STT to transcribe client speech in real time. 4. On final transcript segments, the listener calls an LLM to generate suggested replies. 5. Listener sends suggestions to the specialist’s frontend using LiveKit data messages (targeted to the specialist). 6. Specialist UI displays suggestions for the rep to accept/edit/send. Concrete steps 1) Room setup • Use any LiveKit client SDK (Web, iOS, Android) for client and specialist to connect and publish audio/video. • Ensure participants have identifiable identities so the listener can tell who is speaking. 2) Join the listener as subscribe-only • Connect the listener to the same room but don’t publish audio (so it won’t interrupt). • Auto-subscribe to audio tracks only. 3) Transcribe incoming audio • Subscribe to the room’s audio tracks and feed them to a streaming STT (AssemblyAI, Deepgram, etc.). • Use VAD/turn-detection to avoid transcribing background noise and identify speaker turns. • Process incremental transcripts and wait for final segments before suggesting responses. 4) Generate suggested replies • When a final transcript for the client is available, construct a prompt that includes: ◦ client transcript ◦ relevant context (customer history, product, policies) ◦ role instruction (concise, professional suggested reply) • Send prompt to your LLM and receive suggested text. 5) Deliver suggestions to the specialist • Use LiveKit data messages to send suggestions to the specialist: ◦ Publish a data message from the listener with a topic like
agent_suggestions
. ◦ Send to the specialist’s SID only (destination_sids) or broadcast and filter on the client. • Specialist frontend listens for
dataReceived
events and displays suggestions in the UI. Minimal code examples Listener: connect subscribe-only (pseudo-code)
Copy code
// connect without publishing
await room.connect(wsUrl, token, { publishOnly: false });
room.localParticipant.unpublishAll(); // ensure no audio published
// auto-subscribe to audio tracks (client + specialist)
Listen for audio → STT → final transcript handling (pseudo)
Copy code
on_audio_chunk(track_audio):
  vad_result = vad.detect(track_audio)
  if vad_result.speech:
    stt_stream.send(track_audio)

on_stt_final(transcript, speaker_id):
  if speaker_id == client_id:
    suggestion = generate_suggestion(transcript, context)
    send_suggestion_to_specialist(suggestion, specialist_sid)
Send suggestion via data message (pseudo)
Copy code
// on the listener/server-side
room.localParticipant.publishData(
  new TextEncoder().encode(suggestionText),
  { topic: 'agent_suggestions', destinationSids: [specialistSid] }
);

// on specialist frontend
room.on('dataReceived', (data, participant, topic) => {
  if (topic === 'agent_suggestions') {
    const suggestion = new TextDecoder().decode(data);
    showSuggestionInUI(suggestion);
  }
});
Design considerations and tips • Use speaker IDs and turn-detection so suggestions are only made for the client’s speech. • Prefer final transcripts (or high-confidence partials) to avoid premature suggestions. • Add context (customer profile, previous messages) to LLM prompts for better replies. • Keep suggestions short and mark them as “suggested” — let the human edit/approve. • Log conversation items for compliance and later fine-tuning of prompts. • Apply access controls: send data messages only to the specialist, and avoid broadcasting sensitive suggestions to others. If you’d like, I can: • provide a specific prompt template for the LLM, • show a fuller example using a particular STT provider (Deepgram/AssemblyAI), • or give a sample frontend snippet tailored to Web SDK event handling. Which of those would you like next? Sources: Events and error handling | LiveKit docs | Agent session | LiveKit docs | Agents v0.x migration guide - Python | LiveKit docs | Web and mobile frontends | LiveKit docs | Turn detection and interruptions | LiveKit Docs