Voice Widget
Add a browser-based voice call button to your website so visitors can speak with your AI agent directly.
Voice Widget
Let website visitors talk to your voice agent directly from the browser — no phone number needed. The voice widget adds a call button to your site that connects users via WebRTC for real-time voice conversations.
Quick Setup
Add the voice widget to any webpage:
<script src="https://cdn.thinnest.ai/widget.js"></script>
<script>
ThinnestAI.init({
agentId: 'YOUR_AGENT_ID',
apiKey: 'YOUR_PUBLIC_KEY',
position: 'bottom-right',
theme: 'light',
greeting: 'Click to talk to our AI assistant'
});
</script>A floating call button appears. When clicked, the browser connects to your voice agent via WebRTC.
How It Works
User clicks voice button on your website
↓
Browser requests microphone permission
↓
WebRTC connection established with thinnestAI
↓
User speaks → STT → Agent processes → TTS → User hears response
↓
Call ends when user clicks "Hang up"No phone network is involved — audio travels directly over the internet. Works on all modern browsers (Chrome, Firefox, Safari, Edge).
Widget Configuration
| Option | Type | Default | Description |
|---|---|---|---|
agentId | string | Required | Your voice agent's ID |
apiKey | string | Required | Your publishable API key |
position | string | "bottom-right" | "bottom-right" or "bottom-left" |
theme | string | "light" | "light" or "dark" |
greeting | string | "Talk to us" | Text on the call button |
primaryColor | string | "#0066FF" | Widget accent color |
autoOpen | boolean | false | Auto-start call on page load |
context | object | {} | Data passed to the agent (user info, page context) |
Passing Context
Send page or user context to your agent:
<script>
ThinnestAI.init({
agentId: 'agent_xyz',
apiKey: 'pk_live_abc',
context: {
user_name: 'Jane Doe',
page: 'pricing',
plan: 'payg'
}
});
</script>Your agent can use this context in its responses (e.g., "Hi Jane, I see you're looking at the PAYG plan").
React Component
For React applications:
import { ThinnestVoiceWidget } from '@thinnest/embed-sdk';
function App() {
return (
<ThinnestVoiceWidget
agentId="agent_xyz"
apiKey="pk_live_abc"
position="bottom-right"
theme="light"
onCallStart={(sessionId) => {
console.log('Call started:', sessionId);
}}
onCallEnd={(sessionId, duration) => {
console.log('Call ended, duration:', duration);
}}
/>
);
}React Props
| Prop | Type | Description |
|---|---|---|
agentId | string | Voice agent ID |
apiKey | string | Publishable API key |
position | string | Widget position |
theme | string | Light or dark |
context | object | Context data for the agent |
onCallStart | function | Callback when call starts |
onCallEnd | function | Callback when call ends |
onError | function | Callback on error |
Combined Chat + Voice Widget
Deploy both chat and voice on the same page — the embed widget supports both modes:
<!-- Chat widget with voice enabled -->
<script
src="https://app.thinnest.ai/embed.js"
data-agent-id="YOUR_AGENT_ID"
data-voice-enabled="true"
async
></script>Users can choose to type or speak. The widget shows both a text input and a microphone button.
Browser Requirements
| Browser | Supported | Notes |
|---|---|---|
| Chrome 74+ | Yes | Full support |
| Firefox 66+ | Yes | Full support |
| Safari 14.1+ | Yes | Requires user gesture to start |
| Edge 79+ | Yes | Full support |
| Mobile Chrome | Yes | Works on Android |
| Mobile Safari | Yes | iOS 14.5+ |
Permissions
The browser will ask for microphone permission on the first call. Users must grant access for the voice widget to work. If denied, the widget shows an error message.
Audio Quality
The voice widget uses:
- Opus codec for efficient audio compression
- Echo cancellation built into WebRTC
- Noise suppression for cleaner input
- Adaptive bitrate based on network conditions
For best quality, recommend users use headphones or a quiet environment.
vs Phone Calls
| Feature | Voice Widget | Phone Calls |
|---|---|---|
| Setup | Script tag on website | Twilio/Vobiz number |
| Cost | No telephony charges | Per-minute carrier rates |
| Reach | Website visitors only | Anyone with a phone |
| Quality | High (WebRTC) | Standard (PSTN) |
| Lead capture | Session-based | Phone number captured |
| Mobile | Works in mobile browsers | Native phone experience |
Use the voice widget for website visitors. Use phone calls when you need to reach users on their phones.
Troubleshooting
| Issue | Solution |
|---|---|
| No audio | Check microphone permissions in browser |
| Echo | User should use headphones |
| Widget doesn't load | Verify agentId and apiKey are correct |
| Connection fails | Check network — WebRTC may be blocked by corporate firewalls |
| High latency | Try a closer server region or switch to a faster TTS provider |
| Safari issues | Ensure user clicks the button (autoplay restrictions) |