--- title: Add to Website description: Add your Dograh voice agent to any website so visitors can talk to it. --- ### How to add it Add your voice agent to any website using the Deploy Agent dialog in your agent's settings. Step 1: Open the agent settings by clicking the gear icon in the top-right of the agent editor. ![Open agent settings](../images/open-settings.png) Step 2: Scroll to the **Deployment** section and click **Configure Embed**. ![Go to Deployment](../images/go-to-deployment.png) Step 3: Enable embedding, add your website's domain to **Allowed Domains**, choose **Floating Widget**, **Inline Component**, or **Headless (Bring Your Own UI)**, customize the button (position, color, text) if applicable, and click **Save Configurations**. ![Save configurations](../images/save-configurations.png) Step 4: Copy the generated embed code and paste it into your web page to test your agent. ![Copy deployment code](../images/copy-deployment-code.png) ## Embed modes | Mode | What it renders | When to use | | --------------------- | -------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | | **Floating Widget** | A pill-shaped CTA button anchored to a corner of the page. | You want a turn-key chat-bubble experience that doesn't disturb your existing layout. | | **Inline Component** | A panel rendered inside a `
` that you place in your page. | You want the agent embedded in a specific section (landing-page hero, support tab, etc.). | | **Headless** | No UI. Only the audio pipeline plus a JavaScript API on `window.DograhWidget`. | You want full control over the UI — your own buttons, design system, framework state, animations. | ## Prerequisites These apply to all three modes: - Serve your page over **HTTPS** or from `http://localhost`. Browsers refuse microphone access on plain HTTP origins or `file://`. - If you set **Allowed Domains** in the dashboard, include your test origin (e.g. `localhost`) — otherwise the widget's config and signaling requests are rejected. Leave the list empty to allow all domains. - The embed snippet you copy from the dashboard is a single ` ``` ### React + TypeScript ```tsx import { useEffect, useState } from 'react'; type CallStatus = 'idle' | 'connecting' | 'connected' | 'failed'; declare global { interface Window { DograhWidget: { start: () => void; end: () => void; onStatusChange: (cb: (status: CallStatus, text?: string, subtext?: string) => void) => void; onError: (cb: (err: Error) => void) => void; }; } } export function TalkButton() { const [status, setStatus] = useState('idle'); useEffect(() => { window.DograhWidget.onStatusChange((s) => setStatus(s)); window.DograhWidget.onError((err) => console.error('Dograh error:', err.message)); }, []); const isLive = status === 'connected' || status === 'connecting'; const label = { idle: 'Talk to AI', connecting: 'Connecting…', connected: 'End Call', failed: 'Retry' }[status]; return ( ); } ``` `start()` must run inside a real user-gesture handler (`click`, `touchend`, etc.). Browsers refuse to grant microphone access to scripts that request it outside of one — calling `start()` from a `setTimeout` or on page load will fail with a permission error. ## Lifecycle callbacks (all modes) The `on*` callbacks in the [Headless JavaScript API](#javascript-api) work in **all three embed modes**, not just Headless. Use them for analytics or to trigger UI in the host page even when the widget is rendering its own UI (Floating or Inline). ```js window.DograhWidget.onCallConnected(({ agentId, workflowRunId }) => { analytics.track('voice_call_started', { agentId, workflowRunId }); }); window.DograhWidget.onCallDisconnected(({ workflowRunId, durationSeconds }) => { analytics.track('voice_call_ended', { workflowRunId, durationSeconds }); }); ``` `onCallConnected` and `onCallDisconnected` only fire when the call actually establishes a media connection — failed-to-connect attempts (e.g. denied mic, network failure) don't trigger them, so analytics stay clean.