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

# Website widget

> Embed the Retell AI website widget with one script tag: text chat, in-browser voice calls, or phone callbacks, with no backend proxy required.

The Retell website widget adds your agents to any web page with a single `<script>` tag. Visitors can text-chat with a chat agent, talk to a voice agent in the browser, or request a phone callback. The widget calls the Retell API directly from the browser using your [public key](https://docs.retellai.com/accounts/public-keys.md), so you don't need a backend proxy.

The widget has two modes:

* **Chat and voice widget** (default): text chat, in-browser voice calls, or both in one window.
* **Callback widget**: collects the visitor's name and phone number, then your voice agent calls them.

If you'd rather build your own call UI, use the Web SDK instead. See [make a web call](https://docs.retellai.com/deploy/web-call.md).

![Website widget opened from the floating button in the bottom-right corner, showing the chooser screen titled 'How can we help you today?' with a Voice Assistant option and a Chat Assistant option](https://mintcdn.com/retellai/EGmDwSeJWDFOlOqP/images/website-widget-chooser.png?fit=max\&auto=format\&n=EGmDwSeJWDFOlOqP\&q=85\&s=7efd025a7104015323e5bc9fbc34b0a3)

The widget with both a chat and a voice agent: visitors choose how to talk to you.

## Video tutorial

Walkthrough of embedding the widget on a site and configuring its chat, voice, and callback modes.

[How to use Retell AI Widget](https://www.youtube.com/embed/w8W4AuheIms)

## When to use it

* **Support or sales on your site**: a visitor types a question, or taps **Voice Assistant** to talk to the agent without dialing a number.
* **Voice demo on a landing page**: show prospects your voice agent with a one-click browser call.
* **Callback requests**: a visitor leaves a phone number and your agent calls them right away, for example to qualify a lead or book an appointment.

If you need full control over the UI, or want to start calls from your own app logic, use the [Web SDK](https://docs.retellai.com/deploy/web-call.md) or the [chat API](https://docs.retellai.com/deploy/create-chat-completion.md) instead.

## Prerequisites

1. **An agent for each channel you want to offer:**
   * Text chat needs a [chat agent](https://docs.retellai.com/build/create-chat-agent.md).
   * In-browser voice calls need a voice agent.
   * The callback widget needs a voice agent and a Retell phone number to call from.
2. **A [Retell public key](https://docs.retellai.com/accounts/public-keys.md).** If you restrict the key to specific domains, add the domain that hosts the widget.

## Chat and voice widget

The default widget adds a floating button to the bottom-right corner of your page.

### What do visitors see when they open the widget?

It depends on which agent IDs you set:

| You set | Visitors see |
| - | - |
| `data-agent-id` only | The chat window. |
| `data-voice-agent-id` only | The voice call screen. |
| Both | A chooser with **Voice Assistant** and **Chat Assistant**, plus a tab bar to switch between them. |

> [!WARNING]
>
> Voice calls only use `data-voice-public-key`. They don't fall back to `data-public-key`, so if you offer voice, set `data-voice-public-key` even when it's the same key you use for chat. Without it, the voice screen shows an error.

### Set up the widget

Add the script tag inside your page's `<head>`. Each example below is a complete page you can copy and fill in.

```html Chat and voice theme={"dark"}
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>Retell chat and voice widget</title>
    <script
      id="retell-widget"
      src="https://dashboard.retellai.com/retell-widget-v2.js"
      data-public-key="key_xxxxxxxxxxxxxxxxxxxxx"
      data-voice-public-key="key_xxxxxxxxxxxxxxxxxxxxx"
      data-agent-id="agent_chat_xxxxxxxxxxxxxxx"
      data-voice-agent-id="agent_voice_xxxxxxxxxxx"
      data-title="How can we help?"
      data-color="#FFA07A"
    ></script>
  </head>
  <body></body>
</html>
```

```html Voice only theme={"dark"}
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>Retell voice widget</title>
    <script
      id="retell-widget"
      src="https://dashboard.retellai.com/retell-widget-v2.js"
      data-voice-public-key="key_xxxxxxxxxxxxxxxxxxxxx"
      data-voice-agent-id="agent_voice_xxxxxxxxxxx"
      data-title="Talk to us"
      data-fab-text="Call us now"
    ></script>
  </head>
  <body></body>
</html>
```

```html Chat only theme={"dark"}
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>Retell chat widget</title>
    <script
      id="retell-widget"
      src="https://dashboard.retellai.com/retell-widget-v2.js"
      data-public-key="key_xxxxxxxxxxxxxxxxxxxxx"
      data-agent-id="agent_chat_xxxxxxxxxxxxxxx"
      data-title="Chat with us!"
      data-popup-message="Hi! Need help? Chat with us."
    ></script>
  </head>
  <body></body>
</html>
```

The script tag must keep `id="retell-widget"`; the widget reads its settings from that element.

### How it works

1. The visitor clicks the floating button.
2. If both agents are set, they pick **Voice Assistant** or **Chat Assistant**. Otherwise the widget opens the one channel you configured.
3. **Chat**: the visitor types and the chat agent replies, with a typing indicator while a reply is pending. Chats are saved in the browser's localStorage, so a returning visitor resumes their most recent chat.
4. **Voice**: the visitor starts the call, allows microphone access, and talks to the voice agent over WebRTC. The visitor can mute or hang up from the call screen. If the visitor closes the window mid-call, the call keeps running and they can reopen it to hang up.

![Website widget chat view: the agent greets the visitor for Bright Smile Dental, the visitor asks to book a cleaning this week, and the agent offers Thursday at 10:00 AM or 2:30 PM, with a message input at the bottom](https://mintcdn.com/retellai/EGmDwSeJWDFOlOqP/images/website-widget-chat.png?fit=max\&auto=format\&n=EGmDwSeJWDFOlOqP\&q=85\&s=5681fdbf1a9e7bccde3e35c534f6bb79)

Chat view, with the agent's greeting and reply.

![Website widget voice view showing an animated orb, the title Bright Smile Dental, a Start to call button, and Voice and Chat tabs at the bottom with Voice selected](https://mintcdn.com/retellai/EGmDwSeJWDFOlOqP/images/website-widget-voice.png?fit=max\&auto=format\&n=EGmDwSeJWDFOlOqP\&q=85\&s=534e4969297e4d0e6c0dd96a2f47aed2)

Voice view before the call starts. The tab bar appears when both agents are set.

Voice calls are regular [web calls](https://docs.retellai.com/deploy/web-call.md), so they show up in your call history and trigger the same [webhooks](https://docs.retellai.com/features/register-webhook.md) as other web calls.

### Attributes

**Keys and agents**

| Attribute | Description |
| - | - |
| `data-public-key` | Public key for text chat. Required to offer chat. |
| `data-voice-public-key` | Public key for voice calls. Required to offer voice. Can be the same key as `data-public-key`. |
| `data-agent-id` | Chat agent ID. Enables text chat. |
| `data-voice-agent-id` | Voice agent ID. Enables voice calls. |
| `data-agent-version` | Agent version number. Applies to both the chat and voice agent. If unset, the widget uses the latest version. |
| `data-dynamic` | JSON string of [dynamic variables](https://docs.retellai.com/build/dynamic-variables.md), for example `'{"company": "Acme"}'`. Passed to both chats and voice calls. Invalid JSON is ignored. |

At least one of `data-public-key` or `data-voice-public-key` is required, or the widget doesn't load.

**Appearance**

| Attribute | Default | Description |
| - | - | - |
| `data-title` | None | Title shown on the voice screen. The window header shows the Retell logo, or your `data-logo-url` logo; it shows the title instead only when the widget is white-labeled and has no logo. |
| `data-logo-url` | Retell logo | URL of your logo, shown in the header and on the floating button. |
| `data-fab-text` | `Need support?` | Text on the floating button. |
| `data-fab-icon-url` | Your logo | URL of a custom icon for the floating button. If the image fails to load, the widget falls back to the default icon. |
| `data-color` | None | One hex color for the whole widget. See [colors](#colors). |
| `data-theme-color` | `#071a3e` | Background and theme color. |
| `data-component-color` | `#3E6AEF` | Accent color for buttons and links. |
| `data-chat-font-size` | `default` | Chat text size: `default`, `large` (+2 px), or `extra-large` (+4 px). Any other value falls back to `default`. |

**Behavior**

| Attribute | Default | Description |
| - | - | - |
| `data-auto-open` | `false` | Set to `true` to open the widget on page load. |
| `data-popup-message` | None | A message bubble shown next to the floating button before the visitor opens the widget. No bubble appears unless you set this. |
| `data-bot-name` | `AI Assistant` | Sender name on the popup message. |
| `data-show-ai-popup` | `true` | Set to `false` to turn off the popup message. |
| `data-show-ai-popup-time` | `5` | Seconds to wait before showing the popup message. |

The popup message doesn't appear when `data-auto-open` is `true`.

**Security and branding**

| Attribute | Description |
| - | - |
| `data-recaptcha-key` | Google reCAPTCHA v3 site key. See [reCAPTCHA protection](#recaptcha-protection). |
| `data-white-label` | White-label token that hides "Powered by Retell" branding. Contact Retell to get one. |

### Colors

`data-color` is a shorthand that sets both colors at once:

* The theme color uses `data-color` if set, otherwise `data-theme-color`.
* The accent color uses `data-component-color` if set, otherwise `data-color`.

So for a single-color widget, set `data-color` alone. To control the two colors separately, set `data-theme-color` and `data-component-color` and leave `data-color` out, since `data-color` takes priority over `data-theme-color`.

## Embed the widget in a page section

By default the widget floats in the bottom-right corner. To place it inside your own layout instead, such as a contact section or a dedicated support page, use the embedded build. It renders the chat, voice, or callback panel directly inside a container you control, without the floating button or popup message.

Put the same `data-*` attributes on a container element with `data-retell-widget="true"`, give the container a height, and load `retell-widget-embed.js` once:

```html theme={"dark"}
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>Retell embedded widget</title>
  </head>
  <body>
    <div
      data-retell-widget="true"
      data-public-key="key_xxxxxxxxxxxxxxxxxxxxx"
      data-voice-public-key="key_xxxxxxxxxxxxxxxxxxxxx"
      data-agent-id="agent_chat_xxxxxxxxxxxxxxx"
      data-voice-agent-id="agent_voice_xxxxxxxxxxx"
      style="width: 100%; max-width: 420px; height: 600px"
    ></div>

    <script defer src="https://dashboard.retellai.com/retell-widget-embed.js"></script>
  </body>
</html>
```

* The container must have a `height` or `min-height`. With zero height, the widget is invisible and logs a warning in the browser console.
* Only the first element with `data-retell-widget` on the page is mounted.
* Attributes that control the floating button and popup message have no effect.

**Webflow:** add a Div Block in the Designer and style its size. Add `data-retell-widget="true"` and your widget attributes as custom attributes on the Div Block. Then add the `retell-widget-embed.js` script once under **Site settings > Custom code > Footer code**.

## Callback widget

The callback widget collects the visitor's contact details and has your voice agent call them on the phone.

![Callback widget form titled 'Get a call from us' with first name, last name, a phone number field with a +1 country selector, a privacy policy checkbox, and Submit Request and Maybe later buttons](https://mintcdn.com/retellai/EGmDwSeJWDFOlOqP/images/website-widget-callback.png?fit=max\&auto=format\&n=EGmDwSeJWDFOlOqP\&q=85\&s=200d09b122d9c76b920b8db48690888f)

The callback request form.

### Set up the callback widget

```html theme={"dark"}
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>Retell callback widget</title>
    <script
      id="retell-widget"
      src="https://dashboard.retellai.com/retell-widget-v2.js"
      data-widget="callback"
      data-public-key="key_xxxxxxxxxxxxxxxxxxxxx"
      data-agent-id="agent_voice_xxxxxxxxxxx"
      data-phone-number="+15551234567"
      data-title="Request a Call"
      data-countries="US,CA,GB"
      data-tc="https://example.com/terms"
      data-color="#FFA07A"
      data-fab-text="Get a call from us"
    ></script>
  </head>
  <body></body>
</html>
```

### Callback attributes

**Required**

| Attribute | Description |
| - | - |
| `data-widget="callback"` | Switches the widget to callback mode. |
| `data-public-key` | Your Retell public key. |
| `data-agent-id` | Your voice agent ID (not a chat agent). |
| `data-phone-number` | The Retell phone number that places the call, for example `+15551234567`. |

**Optional**

| Attribute | Description |
| - | - |
| `data-title` | Widget title. |
| `data-countries` | Comma-separated country codes for the phone country selector, for example `US,CA,GB`. |
| `data-tc` | URL of your terms and conditions page. |
| `data-agent-version` | Voice agent version. If unset, uses the latest version. |
| `data-dynamic` | JSON string of [dynamic variables](https://docs.retellai.com/build/dynamic-variables.md) for the call. |
| `data-recaptcha-key` | Google reCAPTCHA v3 site key. See [reCAPTCHA protection](#recaptcha-protection). |

The appearance and branding [attributes](#attributes) of the chat and voice widget also work here.

### How the callback widget works

1. The visitor clicks the floating phone button.
2. They fill in first name, last name, and phone number, and accept the privacy agreement.
3. If reCAPTCHA is enabled, the submission is verified.
4. The widget creates a phone call from `data-phone-number` to the visitor, handled by your voice agent.

## reCAPTCHA protection

Public keys are visible in your page source, so protect them from bots with Google reCAPTCHA v3. The widget supports **reCAPTCHA v3 only**. When enabled, the widget requests a token for each new chat, voice call, and callback request.

1. Load the reCAPTCHA v3 script in your page's `<head>`:
   ```html theme={"dark"}
   <script src="https://www.google.com/recaptcha/api.js?render=YOUR_GOOGLE_RECAPTCHA_SITE_KEY"></script>
   ```
2. Add `data-recaptcha-key="YOUR_GOOGLE_RECAPTCHA_SITE_KEY"` to the widget.
3. Turn on reCAPTCHA for your public key in [public key settings](https://docs.retellai.com/accounts/public-keys.md).

See [prevent abuse](https://docs.retellai.com/reliability/prevent-abuse.md) for other ways to protect your public endpoints.

## Test the widget

1. Load your page and click the floating button (or scroll to your container, for the embedded build).
2. For chat, send a message and check that the agent replies.
3. For voice, start a call, allow microphone access, and talk to the agent.
4. For callback, submit the form with your own number and wait for the call.

If the widget doesn't appear, open the browser console. The widget logs setup errors there.

## FAQ

> [accordion] How do I remove the "Powered by Retell" branding?
>
> Contact [Retell support](mailto:support@retellai.com) for a white-label token, then add it to the widget as `data-white-label`. It works for both the floating and embedded widget, in every mode.

> [accordion] The widget doesn't show up on my site. What should I check?
>
> Open the browser console and look for a `Retell Widget` error. Check that the script tag keeps `id="retell-widget"`, that you set at least one public key, and that your public key allows your site's domain. If you recently updated the widget settings, hard-refresh the page (Ctrl+Shift+R or Cmd+Shift+R) to clear a cached copy of the script.

> [accordion] Can I use the widget on Wix or Webflow?
>
> Yes. Paste the script tag into your site builder's custom code setting so it loads on every page. For Webflow, you can also use the [embedded build](#embed-the-widget-in-a-page-section) to place the widget inside a section.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.