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

# Add a voice agent to your website with the web widget

> Paste two lines of code to put a Bolna voice agent on any website. Visitors talk to your agent from the browser, with no backend of your own: a public key limits which agents, domains and how many calls.

The web widget is a ready-made call button for any website. Paste it into your page and visitors talk to your Bolna voice agent straight from the browser. It works on plain HTML, React, Next.js, Vue, Angular, WordPress and Webflow.

You don't need a backend. The widget uses a **public key** (`pk_...`) that is meant to sit in page HTML: it can only start web calls to agents in your account, within the limits you set, and browsers only start those calls from the domains you list.

## How it works

```mermaid theme={"system"}
sequenceDiagram
    participant Visitor as Visitor's browser (widget)
    participant Bolna as Bolna
    Visitor->>Bolna: 1. Start a call with the public key and agent id
    Note over Bolna: Checks the website's domain, the agent,<br/>the variables and the key's limits
    Bolna-->>Visitor: 2. Short-lived call session
    Visitor->>Bolna: 3. Live, two-way audio with your agent
```

Every call is checked before it starts. A call from a domain that isn't on the key, to an agent outside your account, or over the key's limits is refused.

## Set it up in the dashboard

**1. Open the Web widget tab**

In the Bolna dashboard, go to **Developers** and open the **Web widget** tab.

**2. Create a widget key**

A key belongs to your account, not to one agent: it works with any of your agents. Give it a name and choose:

* **Allowed domains**: the websites the widget may run on, for example `acme.com` and `*.acme.com`. Press Space or Enter after each one. See [allowed domains](#allowed-domains).
* **Allowed prompt variables**: the variable names a page may fill in, for example `name` or `page`, again with Space or Enter after each. Leave it empty if the page passes none.
* **Concurrent calls** and the other [limits](#limits). The defaults suit most websites.

**3. Design the widget**

Below the keys, under **Set up the widget**, pick the agent, the key and a style, then set the heading, subheading, colour, position and theme. The preview beside these settings runs the real widget: click it to place a test call with your agent.

**4. Copy the code**

Under **Code**, choose your stack (HTML, React, Next.js, Vue, Angular, or WordPress / Webflow), copy the code and paste it into your site.

## Add the code to your site

The dashboard writes the code for you. For a plain HTML page it looks like this; paste it before `</body>`:

```html theme={"system"}
<!-- public-key is your public key (pk_...). It is meant for page HTML and can only start web calls, within the key's limits. -->
<bolna-widget agent-id="YOUR_AGENT_ID" public-key="pk_..." variant="pill"></bolna-widget>
<script src="https://cdn.jsdelivr.net/gh/bolna-ai/web-call@v3.1.0/dist/bolna-widget.min.js" async></script>
```

In an app built with npm, install the SDK and import the widget once:

```bash npm theme={"system"}
npm install @bolna/web-call
```

```javascript import theme={"system"}
import "@bolna/web-call/widget";
```

Then use the `<bolna-widget>` tag in your templates. React, Next.js, Vue and Angular each need a one-line setting to accept a custom tag; the code the dashboard writes for each stack includes it.

> [!NOTE]
>
> The widget draws itself in a shadow DOM, so your site's CSS can't change or break it. Calls start from a visitor's click, which browsers require before playing audio.

## Attributes

| Attribute | Default | Description |
| - | - | - |
| `agent-id` | required | The agent to call: any agent in the key's account. |
| `public-key` | required | The widget key (`pk_...`) from the dashboard. |
| `variant` | `pill` | The style: `pill` (mic, heading and subheading, floating), `orb` (the mic alone, floating), `button` (a solid button with the heading, floating), `card` (sits inside your page). |
| `heading` | `Talk to Bolna` | The main line of text. |
| `subheading` | `Say in any language you speak` | The second line, shown while the widget is idle. |
| `color` | `#141414` | The colour of the mic and the button. |
| `position` | `bottom-right` | Where a floating widget sits: `bottom-right`, `bottom-left` or `bottom-center`. Not used by `card`. |
| `theme` | `light` | `light` or `dark`. |
| `language` | the agent's default | The language to start the call in. It must be one of the languages the agent is set up with. |
| `variables` | none | A JSON object of prompt variables. See [Pass variables](#pass-variables-to-the-agent). |
| `api-base-url` | `https://api.bolna.ai` | Bolna's API. Change it only if Bolna support asks you to. |

While a call is live, the ring around the mic moves with the agent's voice and a mute button appears. Clicking the widget again ends the call.

## Pass variables to the agent

Fill `{variable}` placeholders in the agent's prompt and welcome message from the page, the same way `user_data` works for phone calls:

```html theme={"system"}
<bolna-widget
  agent-id="YOUR_AGENT_ID"
  public-key="pk_..."
  variables='{"name": "Asha", "page": "pricing"}'>
</bolna-widget>
```

* Only the variable names listed under **Allowed prompt variables** on the key are accepted. A call that sends any other name is refused.
* Each value is text, a number or true/false, at most 500 characters. All variables together can be at most 2 KB.
* Anyone can read and change what a page sends, so never use variables for anything you need to trust, such as a customer's account id or a price.

## Listen to widget events

The widget fires DOM events you can send to your analytics:

| Event | `event.detail` | Fires when |
| - | - | - |
| `call-start` | none | The agent answered. |
| `call-end` | `{ reason }` | The call ended: `local-hangup`, `remote-hangup` or `failed`. |
| `error` | `{ code }` | A call couldn't start or failed. The codes are listed in the [SDK error codes](https://www.bolna.ai/docs/developer-resources/sdks/web-call-api.md#error-codes). |

```javascript theme={"system"}
const widget = document.querySelector("bolna-widget");
widget.addEventListener("call-start", () => analytics.track("voice_call_started"));
widget.addEventListener("call-end", (event) => analytics.track("voice_call_ended", event.detail));
widget.addEventListener("error", (event) => console.warn("Bolna widget:", event.detail.code));
```

`error` doesn't bubble, so listen on the widget element itself.

## Allowed domains

A call is refused unless the visitor's website is on the key's allowed domains.

> [!NOTE]
>
> The domain check reads the website the browser reports. It stops other websites from using your key in their visitors' browsers, but a script running outside a browser can claim any website. What caps misuse is the key's [limits](#limits): calls per visitor, new calls per minute and per day, concurrent calls and the longest call. If a key is misused, create a new key, update your site, and revoke the old one.

| Entry | Matches |
| - | - |
| `acme.com` | `https://acme.com` only |
| `*.acme.com` | Any subdomain over HTTPS, such as `https://www.acme.com` and `https://shop.acme.com`, but not `acme.com` itself. Add both entries to cover both. |
| `localhost`, `127.0.0.1` | Local testing on any port, over HTTP or HTTPS |

* Enter a hostname only, with no `https://`, port or path. A key can list up to 20 domains.
* Every other website must use HTTPS.
* Wildcards aren't allowed on shared hosting domains such as `*.vercel.app`, `*.netlify.app` or `*.github.io`, because they would match other people's sites. List your full hostname instead, for example `acme.vercel.app`.

## Limits

Each key has its own limits, which you set when you create or edit it:

| Limit | Default | Range | What it limits |
| - | - | - | - |
| Concurrent calls | your account's web-call concurrency | 1 up to your account's web-call concurrency | Live calls on this key at once |
| New calls per minute | 30 | 1 to 120 | New calls on this key across all visitors |
| Calls per day | 500 | 10 to 5,000 | Calls on this key in a day |
| Calls per minute, per visitor | 3 | 1 to 10 | Calls from one visitor's IP address in a minute |
| Calls per day, per visitor | 20 | 5 to 100 | Calls from one visitor's IP address in a day |
| Longest call (seconds) | 600 | 60 to 1,800 | How long a widget call may last. The call ends when it reaches the limit. |

* **Web-call concurrency is shared.** Widget calls count toward your account's web-call concurrency, together with your other web calls. The Web widget tab shows your account's number as **Concurrent web calls**. [Contact support](https://www.bolna.ai/docs/getting-help.md) to raise it.
* An organization can have up to **10 active keys**.
* Visitors who share one IP address, such as an office network, share the per-visitor limits.

## What a public key can and can't do

A public key is meant to be seen: anyone can read it from your page. It is built so that this is safe.

* It can **only start web calls**, to agents in your account, within the key's limits.
* Browsers only start those calls from the domains on the key. The domain comes from the browser, so a script outside a browser can still use the key, and the key's limits are what cap it.
* It **can't read or change anything** in your account. Every other Bolna API refuses it with `403`.
* Calls placed with it are billed to your account and show up in your call history, like your other web calls.

Your `bn-` API key is different: it must never be put in a web page.

If a key is copied somewhere you don't want, create a new key, update your site, and revoke the old one. Changes to a key's domains, variables and limits, and revoking it, apply to the next call.

## Build your own button

To use your own design instead of the widget, use the [Web Call SDK](https://www.bolna.ai/docs/developer-resources/sdks/web-call) with the public key. You get the SDK's events, mute and volume level, with no backend:

```javascript theme={"system"}
import { BolnaWebCall } from "@bolna/web-call";

const call = new BolnaWebCall({
  publicKey: "pk_...",
  agentId: "YOUR_AGENT_ID",
  userData: { name: "Asha" }, // sent as variables: only names the key allows
});
document.querySelector("#talk").addEventListener("click", () => call.start());
```

See the [SDK API reference](https://www.bolna.ai/docs/developer-resources/sdks/web-call-api.md) for every option.

## Manage keys with the API

You can also create, list, edit and revoke widget keys with your `bn-` API key. See the [web widget keys API](https://www.bolna.ai/docs/api-reference/web-widget/overview).

## Troubleshooting

| What the visitor sees | Likely cause | What to do |
| - | - | - |
| Unavailable right now | The key was revoked or mistyped, the agent id isn't an agent in the key's account, or the website isn't on the key's allowed domains. | Open the browser console: the error message names the check that refused the call. Fix the key in **Developers > Web widget**. |
| All lines are busy, try again shortly | A limit was reached: concurrent calls, or one of the per-minute or per-day limits. | Raise the key's limits, or [contact support](https://www.bolna.ai/docs/getting-help.md) to raise your web-call concurrency. |
| Allow the microphone to talk | The visitor blocked the microphone. | The visitor allows the microphone in the browser's site settings and clicks again. |
| Couldn't connect, try again | The visitor's network blocked the call, or the connection dropped. | Try again on another network. |
| Nothing appears | The script didn't load. | Check the script tag. If your site sets a Content Security Policy, allow `cdn.jsdelivr.net` in `script-src`, and `https://api.bolna.ai` and `wss:` in `connect-src`. |

## FAQ

> [accordion] Do I need a server?
>
> No. The public key replaces the backend session route that the [Web Call SDK](https://www.bolna.ai/docs/developer-resources/sdks/web-call) normally needs. If you already run that route, you can keep using it with the SDK.

> [accordion] Can I use the widget in a mobile app?
>
> No. Allowed domains are checked against the website a browser reports, and native apps don't report one. Mobile apps use the [mobile SDKs](https://www.bolna.ai/docs/developer-resources/sdks/web-call-platforms.md) with a session route on your backend.

> [accordion] Can I put more than one widget on a page?
>
> Yes. Each `<bolna-widget>` places its own calls and can use a different agent or style. Each visitor's calls still count toward the key's per-visitor limits.


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