Conversation Bar

PreviousNext

A complete voice conversation interface with microphone controls, text input, and real-time waveform visualization for ElevenLabs agents.

Installation

pnpm dlx @elevenlabs/agents-cli@latest components add conversation-bar

Usage

import { ConversationBar } from "@/components/ui/conversation-bar"

Basic Usage

<ConversationBar
  agentId="your-agent-id"
  onConnect={() => console.log("Connected")}
  onDisconnect={() => console.log("Disconnected")}
  onMessage={(message) => console.log("Message:", message)}
  onError={(error) => console.error("Error:", error)}
/>

With Custom Styling

<ConversationBar
  agentId="your-agent-id"
  className="max-w-2xl"
  waveformClassName="bg-gradient-to-r from-blue-500 to-purple-500"
  onConnect={() => console.log("Connected")}
/>

API Reference

ConversationBar

A complete voice conversation interface with WebRTC support, microphone controls, text input, and real-time waveform visualization.

Props

PropTypeDescription
agentIdstringRequired. ElevenLabs Agent ID to connect to
classNamestringOptional CSS classes for the container
waveformClassNamestringOptional CSS classes for the waveform
onConnect() => voidCallback when conversation connects
onDisconnect() => voidCallback when conversation disconnects
onError(error: Error) => voidCallback when an error occurs
onMessage(message: { source: "user" | "ai"; message: string }) => voidCallback when a message is received

Features

  • Voice Input: Connect to ElevenLabs agents via WebRTC for real-time voice conversations
  • Text Input: Expandable keyboard input with contextual updates
  • Microphone Controls: Mute/unmute toggle with visual feedback
  • Live Waveform: Real-time audio visualization during conversations
  • Connection States: Visual feedback for disconnected, connecting, connected, and disconnecting states
  • Keyboard Shortcuts: Enter to send messages, Shift+Enter for new lines
  • Responsive Design: Works seamlessly across desktop and mobile devices

Notes

  • Requires the @elevenlabs/react package for conversation management
  • Uses WebRTC for real-time audio streaming
  • Automatically requests microphone permissions when starting a conversation
  • Cleans up media streams on component unmount
  • Text input sends contextual updates to the agent while typing
  • The waveform visualizes microphone input in real-time when connected and unmuted