Widget Embedding Guide
Add a voice agent to any website. No framework required, no build step needed. The widget ships as a self-contained bundle with its own Preact runtime (~160KB gzipped), six layout modes, full design-token theming, and built-in voice activity detection. It works from a CDN or as an ES module, and tears down cleanly for single-page apps.
The widget bundles everything internally. No React or build tooling required. For React-native integration, see React UI Components.
Quick Start
Install
ES Module
Replace YOUR_AGENT_ID with a Reusable Agent Configuration UUID, or pass an inline agent config object instead. See Agent Configuration for both patterns.
CDN
Load the widget from cdn.deepgram.com for a no-build path:
The latest segment in the URL above is replaced with the current pinned version when this page loads, so the snippet you copy targets a specific build, not a moving release pointer.
Self-hosted UMD
The package ships a UMD bundle at dist/widget.umd.js for <script>-tag usage. Copy or symlink it from node_modules/@deepgram/agents-widget/dist/widget.umd.js into your static assets, then load it like any other script:
Never include your API key in client-side code. Use tokenFactory to fetch short-lived tokens from your server. The apiKey option exists only for local development.
Layouts
The widget ships with six layout modes. Set the layout option to choose one.
sidebar (default)
A panel that slides in from the edge of the screen. Toggled by a floating action button (FAB).
floating
A FAB button that reveals a floating overlay panel.
inline
Mounts directly into an existing DOM element. No FAB, no overlay.
embedded
Full-width card with configurable aspect ratio. Includes the conversation transcript. Ideal for landing pages and product demos.
button
A single talk button — press to start, press again to stop. Minimal footprint.
orb
The Deepgram animated hoop visualization with start/stop controls. Audio-reactive — the orb responds to input and output volume in real time.
Placement
For layouts with a FAB (sidebar, floating, button, orb), set where the button appears:
External Trigger Button
To use your own button instead of the built-in FAB, pass its element ID:
To toggle the widget programmatically from anywhere:
Features
Toggle UI features on or off:
VAD Configuration
Enable Silero VAD to gate audio so only speech frames reach the agent. Pass true for defaults, or fine-tune the thresholds:
When VAD is enabled, the microphone captures continuously but transmits only when speech is detected. This reduces bandwidth and improves turn-taking accuracy.
Text Customization
Override labels and placeholder text:
Agent Overrides
Override the agent’s system prompt or greeting for this session without changing the agent configuration in the Deepgram console:
Callbacks
Listen to agent lifecycle events for analytics, logging, or UI integration:
Color Scheme
Control how the widget adapts to light and dark mode:
The class-based option watches for a CSS selector on any ancestor element. Use it when the host app controls theme via a class on <html> rather than OS preference.
Theming
Customize the widget’s appearance by overriding design tokens. Each property maps to a CSS custom property on the widget root element ([data-dg-agent]). Set a token here to override the built-in adaptive default in both light and dark modes.
To override only one color scheme, skip the theme option and write CSS directly:
Embedded Layout Tokens
The embedded layout supports additional sizing tokens:
Full Configuration Reference
Cleanup
The init() function returns a teardown function. Call it to unmount the widget, remove all injected styles, and release audio resources. This is essential for single-page apps where the widget mounts and unmounts as the user navigates.
For frameworks with lifecycle hooks, call teardown in the cleanup phase: