> ## Documentation Index
> Fetch the complete documentation index at: https://docs.asisso.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Add to Website

> Add your Asisso voice agent to any website so visitors can talk to it.

### How to add it

Add your voice agent to any website using the Configure Widget 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.

<img src="https://mintcdn.com/asisso-cd509912/QZnK0Tlqk8NEH_06/images/open-settings.png?fit=max&auto=format&n=QZnK0Tlqk8NEH_06&q=85&s=a92229f5e577ca425b73a224af09eaea" alt="Open agent settings" width="2880" height="1557" data-path="images/open-settings.png" />

Step 2: Scroll to the **Add to Website** section and click **Configure Widget**.

<img src="https://mintcdn.com/asisso-cd509912/QZnK0Tlqk8NEH_06/images/add-to-website.png?fit=max&auto=format&n=QZnK0Tlqk8NEH_06&q=85&s=2ecaf7bce085c35e8858fb847025dcaa" alt="Go to Add to Website" width="2850" height="1558" data-path="images/add-to-website.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**.

<img src="https://mintcdn.com/asisso-cd509912/QZnK0Tlqk8NEH_06/images/save-configurations.png?fit=max&auto=format&n=QZnK0Tlqk8NEH_06&q=85&s=a4b86793c28696aa5c8f6b1b2360fb39" alt="Save configurations" width="1974" height="1534" data-path="images/save-configurations.png" />

Step 4: Copy the generated embed code and paste it into your web page to test your agent.

<img src="https://mintcdn.com/asisso-cd509912/QZnK0Tlqk8NEH_06/images/copy-deployment-code.png?fit=max&auto=format&n=QZnK0Tlqk8NEH_06&q=85&s=94fcd2c25d563d00b37303dfc0972f69" alt="Copy deployment code" width="2880" height="1537" data-path="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 `<div id="asisso-inline-container">` 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.AsissoWidget`.              | 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 `<script>` tag that loads `asisso-widget.js` **asynchronously**. The widget auto-initializes once it loads and exposes `window.AsissoWidget`. Code that registers callbacks must wait for the widget to be available.

## Floating Widget

<img src="https://mintcdn.com/asisso-cd509912/QZnK0Tlqk8NEH_06/images/floating-widget-example.png?fit=max&auto=format&n=QZnK0Tlqk8NEH_06&q=85&s=8d059e3e84f974513fd19a73f127f08c" alt="Floating widget shown in the corner of a host page" width="2880" height="1555" data-path="images/floating-widget-example.png" />

Renders a pill-shaped button (microphone icon + text) anchored to a corner of the page. Clicking it starts a call; clicking again ends it. The button auto-updates its label and color across the call lifecycle: configured text → "Connecting…" → "End Call" → "Retry" on failure.

Configure **Button Text**, **Button Color**, and **Position** (top/bottom + left/right) from the dashboard.

The host page writes no JavaScript — pasting the embed snippet is the entire integration. If you want to subscribe to call lifecycle events (e.g. analytics), see [Lifecycle callbacks](#lifecycle-callbacks-all-modes) below

## Inline Component

<img src="https://mintcdn.com/asisso-cd509912/QZnK0Tlqk8NEH_06/images/inline-widget-example.png?fit=max&auto=format&n=QZnK0Tlqk8NEH_06&q=85&s=f02086b1a703543bac73db5b6f8c294a" alt="Inline widget rendered inside a page section" width="2844" height="1555" data-path="images/inline-widget-example.png" />

Renders a panel (status icon + status text + CTA button) inside a `<div>` you place in your page. Status changes update the panel in place.

Configure **Button Text**, **Button Color**, and **Call to Action Text** from the dashboard.

### Plain HTML

Place a container `<div>` where you want the widget to render. The widget auto-attaches to it.

```html theme={null}
<!-- Paste the asisso embed snippet from the dashboard somewhere on the page -->
<div id="asisso-inline-container"></div>
```

### React

Because React mounts after the widget script may have already loaded, integrate via `initInline` on first mount and `refresh` on remount. Poll for `window.AsissoWidget` to handle the async script load.

```tsx theme={null}
import { useEffect } from 'react';

declare global {
  interface Window {
    AsissoWidget?: {
      initInline: (options: { container: HTMLElement }) => void;
      refresh: () => void;
      getState: () => { isInitialized: boolean };
    };
  }
}

export function Assistant() {
  useEffect(() => {
    let retries = 0;
    const tryInit = () => {
      const container = document.getElementById('asisso-inline-container');
      if (window.AsissoWidget && container) {
        const { isInitialized } = window.AsissoWidget.getState();
        if (isInitialized) window.AsissoWidget.refresh();
        else window.AsissoWidget.initInline({ container });
      } else if (retries++ < 50) {
        setTimeout(tryInit, 100);
      }
    };
    tryInit();
  }, []);

  return <div id="asisso-inline-container" />;
}
```

## Headless Mode

<img src="https://mintcdn.com/asisso-cd509912/QZnK0Tlqk8NEH_06/images/headless-widget-example.png?fit=max&auto=format&n=QZnK0Tlqk8NEH_06&q=85&s=24d85fa379f544e4c794d07b739f2526" alt="Headless widget driven by host-page UI" width="2842" height="1548" data-path="images/headless-widget-example.png" />

In Headless mode the widget injects no UI of its own. You render whatever buttons, banners, or in-call indicators you want, and call the JavaScript API to start and end calls.

### JavaScript API

| Method / Callback                            | Description                                                                                                                            |
| -------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
| `window.AsissoWidget.start()`                | Begin a voice call. Must be called from inside a user-gesture handler (e.g. `click`) so the browser grants microphone access.          |
| `window.AsissoWidget.end()`                  | End the active call.                                                                                                                   |
| `window.AsissoWidget.onCallStart(cb)`        | Fires when `start()` is invoked (status `connecting`). No payload.                                                                     |
| `window.AsissoWidget.onCallConnected(cb)`    | Fires when the WebRTC connection is established. Payload: `{ agentId, workflowRunId, token }`.                                         |
| `window.AsissoWidget.onCallDisconnected(cb)` | Fires only if the call had connected, when teardown runs. Payload: `{ agentId, workflowRunId, token, durationSeconds }`.               |
| `window.AsissoWidget.onCallEnd(cb)`          | Fires whenever the call session is torn down (including failed-to-connect attempts). No payload.                                       |
| `window.AsissoWidget.onStatusChange(cb)`     | Fires on every status change. Callback receives `(status, text, subtext)`. Status values: `idle`, `connecting`, `connected`, `failed`. |
| `window.AsissoWidget.onError(cb)`            | Fires on errors (mic permission denied, server error, etc.). Callback receives an `Error` object.                                      |

All `on*` setters are single-listener — calling the same one again replaces the previous handler.

<Note>
  **About timing.** The widget script loads asynchronously, so `window.AsissoWidget` may not exist at the moment your inline `<script>` first runs. The examples below assume `window.AsissoWidget` is already available when registration runs. To guarantee that:

  * **Vanilla JS:** wrap your registration code in `window.addEventListener('load', () => { /* register here */ })`.
  * **React:** inside `useEffect`, register immediately if `document.readyState === 'complete'`, otherwise add a one-time `window.load` listener that registers on fire.
  * **Click handlers** that call `start()` / `end()` don't need a guard — by the time a user clicks, the widget has long since loaded.
</Note>

### Vanilla JS

```html theme={null}
<button id="talk-btn">Talk to AI</button>

<script>
  let callStatus = 'idle';
  const btn = document.getElementById('talk-btn');

  function render() {
    btn.textContent =
      callStatus === 'connected' ? 'End Call'
      : callStatus === 'connecting' ? 'Connecting…'
      : callStatus === 'failed' ? 'Retry'
      : 'Talk to AI';
  }

  window.AsissoWidget.onStatusChange((status) => {
    callStatus = status;
    render();
  });

  window.AsissoWidget.onError((err) => {
    console.error('Asisso error:', err.message);
  });

  btn.addEventListener('click', () => {
    if (callStatus === 'connected' || callStatus === 'connecting') {
      window.AsissoWidget.end();
    } else {
      window.AsissoWidget.start();
    }
  });
</script>
```

### React + TypeScript

```tsx theme={null}
import { useEffect, useState } from 'react';

type CallStatus = 'idle' | 'connecting' | 'connected' | 'failed';

declare global {
  interface Window {
    AsissoWidget: {
      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<CallStatus>('idle');

  useEffect(() => {
    window.AsissoWidget.onStatusChange((s) => setStatus(s));
    window.AsissoWidget.onError((err) => console.error('Asisso error:', err.message));
  }, []);

  const isLive = status === 'connected' || status === 'connecting';
  const label = { idle: 'Talk to AI', connecting: 'Connecting…', connected: 'End Call', failed: 'Retry' }[status];

  return (
    <button onClick={() => (isLive ? window.AsissoWidget.end() : window.AsissoWidget.start())}>
      {label}
    </button>
  );
}
```

<Note>
  `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.
</Note>

## 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 theme={null}
window.AsissoWidget.onCallConnected(({ agentId, workflowRunId }) => {
  analytics.track('voice_call_started', { agentId, workflowRunId });
});

window.AsissoWidget.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.
