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

# Widget SDK

> Embeddable conversation widget for Oration AI agents

## Overview

The Oration Widget SDK is a lightweight, embeddable web component (`<oration-widget>`) that adds AI voice and chat agents to any website. No framework or build step required — just a script tag.

## Quick start

```html theme={null}
<body>
    <oration-widget public-key="your-public-key" default-agent-id="your-agent-id">
    </oration-widget>
    <script src="https://unpkg.com/@oration/widget/dist/index.umd.js"></script>
</body>
```

<img className="block dark:hidden" src="https://mintcdn.com/oration/30YYqnCV1Lr1_fNI/images/widget-full-initial-view.png?fit=max&auto=format&n=30YYqnCV1Lr1_fNI&q=85&s=da4b17df0a19a4258d100b2057715cea" alt="Widget initial view - Ready to talk button" width="188" height="96" data-path="images/widget-full-initial-view.png" />

<img className="hidden dark:block" src="https://mintcdn.com/oration/30YYqnCV1Lr1_fNI/images/widget-full-initial-view.png?fit=max&auto=format&n=30YYqnCV1Lr1_fNI&q=85&s=da4b17df0a19a4258d100b2057715cea" alt="Widget initial view - Ready to talk button" width="188" height="96" data-path="images/widget-full-initial-view.png" />

## Getting your keys

1. **Public key** — copy your workspace public key from the [Oration Dashboard](https://www.oration.ai/app)
2. **Agent ID** — create an agent and copy its ID from the agents section

## Configuration

### Required attributes

| Attribute          | Type   | Description                           |
| ------------------ | ------ | ------------------------------------- |
| `public-key`       | string | Your Oration workspace public key     |
| `default-agent-id` | string | The agent ID to use for conversations |

### Optional attributes

| Attribute                  | Type        | Default                                     | Description                                                           |
| -------------------------- | ----------- | ------------------------------------------- | --------------------------------------------------------------------- |
| `conversation-type`        | string      | `"web"`                                     | `"web"`, `"chat"`, or `"both"`                                        |
| `agent-language-id-map`    | JSON string | —                                           | Map of BCP-47 language codes to agent IDs                             |
| `size`                     | string      | `"full"`                                    | `"full"` (380px) or `"tiny"` (260px)                                  |
| `position`                 | string      | `"bottom-right"`                            | `"bottom-right"`, `"bottom-left"`, `"top-right"`, `"top-left"`        |
| `color-mode`               | string      | `"system"`                                  | `"light"`, `"dark"`, or `"system"`                                    |
| `theme`                    | JSON string | —                                           | Custom theme colors (see [Theme customization](#theme-customization)) |
| `dynamic-variables`        | JSON string | —                                           | `Record<string, string>` passed as session context to the agent       |
| `logo`                     | string      | —                                           | URL of a custom logo to replace the default                           |
| `animate-logo`             | boolean     | `true` for default logo, `false` for custom | Control logo spin animation                                           |
| `main-label`               | string      | —                                           | Override the initial "Ready to start" label                           |
| `orb-color`                | string      | —                                           | Hex color for the AI orb (e.g. `"#2563eb"`)                           |
| `require-terms-acceptance` | boolean     | `false`                                     | Show a terms acceptance gate before the first conversation            |
| `terms-text`               | string      | —                                           | Custom terms text (used when `require-terms-acceptance` is enabled)   |
| `enable-dtmf`              | boolean     | `false`                                     | Show a DTMF numpad during voice calls                                 |

## Conversation types

### Web mode (default)

Real-time voice conversation.

```html theme={null}
<oration-widget
    public-key="pk_your_public_key_here"
    default-agent-id="asst_your_assistant_id_here">
</oration-widget>
```

<img className="block dark:hidden" src="https://mintcdn.com/oration/lhdm7ZGflADIrWsU/images/widget-full-voice-live.png?fit=max&auto=format&n=lhdm7ZGflADIrWsU&q=85&s=6c9536727d60178bfcafd83f158b7282" alt="Widget in voice conversation mode with live transcript" width="386" height="423" data-path="images/widget-full-voice-live.png" />

<img className="hidden dark:block" src="https://mintcdn.com/oration/lhdm7ZGflADIrWsU/images/widget-full-voice-live.png?fit=max&auto=format&n=lhdm7ZGflADIrWsU&q=85&s=6c9536727d60178bfcafd83f158b7282" alt="Widget in voice conversation mode with live transcript" width="386" height="423" data-path="images/widget-full-voice-live.png" />

### Chat mode

Text-based chat interface.

```html theme={null}
<oration-widget
    public-key="pk_your_public_key_here"
    default-agent-id="asst_your_assistant_id_here"
    conversation-type="chat">
</oration-widget>
```

<img className="block dark:hidden" src="https://mintcdn.com/oration/30YYqnCV1Lr1_fNI/images/widget-full-chat-live.png?fit=max&auto=format&n=30YYqnCV1Lr1_fNI&q=85&s=6177e1ac48e4ead36664d3975b92293c" alt="Widget in chat mode with text conversation" width="385" height="417" data-path="images/widget-full-chat-live.png" />

<img className="hidden dark:block" src="https://mintcdn.com/oration/30YYqnCV1Lr1_fNI/images/widget-full-chat-live.png?fit=max&auto=format&n=30YYqnCV1Lr1_fNI&q=85&s=6177e1ac48e4ead36664d3975b92293c" alt="Widget in chat mode with text conversation" width="385" height="417" data-path="images/widget-full-chat-live.png" />

### User choice mode

Lets users pick between voice and chat.

```html theme={null}
<oration-widget
    public-key="pk_your_public_key_here"
    default-agent-id="asst_your_assistant_id_here"
    conversation-type="both">
</oration-widget>
```

<img className="block dark:hidden" src="https://mintcdn.com/oration/lhdm7ZGflADIrWsU/images/widget-full-select-mode.png?fit=max&auto=format&n=lhdm7ZGflADIrWsU&q=85&s=d3fd09e448fb68d07391eef6292665f6" alt="Widget conversation type selector - Voice or Chat options" width="395" height="177" data-path="images/widget-full-select-mode.png" />

<img className="hidden dark:block" src="https://mintcdn.com/oration/lhdm7ZGflADIrWsU/images/widget-full-select-mode.png?fit=max&auto=format&n=lhdm7ZGflADIrWsU&q=85&s=d3fd09e448fb68d07391eef6292665f6" alt="Widget conversation type selector - Voice or Chat options" width="395" height="177" data-path="images/widget-full-select-mode.png" />

## Widget sizes

| Value              | Width | Use case                     |
| ------------------ | ----- | ---------------------------- |
| `"full"` (default) | 380px | Standard widget with full UI |
| `"tiny"`           | 260px | Compact, minimal footprint   |

<img className="block dark:hidden" src="https://mintcdn.com/oration/lhdm7ZGflADIrWsU/images/widget-tiny-voice-live.png?fit=max&auto=format&n=lhdm7ZGflADIrWsU&q=85&s=1580792bc642b5a7809bf680c02f767a" alt="Tiny widget size during voice conversation" width="292" height="101" data-path="images/widget-tiny-voice-live.png" />

<img className="hidden dark:block" src="https://mintcdn.com/oration/lhdm7ZGflADIrWsU/images/widget-tiny-voice-live.png?fit=max&auto=format&n=lhdm7ZGflADIrWsU&q=85&s=1580792bc642b5a7809bf680c02f767a" alt="Tiny widget size during voice conversation" width="292" height="101" data-path="images/widget-tiny-voice-live.png" />

## Multi-language support

Map BCP-47 language codes to specific agent IDs. A language selector will appear in the widget when the map contains at least one entry.

```html theme={null}
<oration-widget
    public-key="pk_your_public_key_here"
    default-agent-id="asst_english_agent_id"
    agent-language-id-map='{"en-US": "asst_english_agent_id", "es-ES": "asst_spanish_agent_id", "hi-IN": "asst_hindi_agent_id"}'>
</oration-widget>
```

<img className="block dark:hidden" src="https://mintcdn.com/oration/30YYqnCV1Lr1_fNI/images/widget-full-language-selector.png?fit=max&auto=format&n=30YYqnCV1Lr1_fNI&q=85&s=5fe4bbd325837eb4e8baabaf6520ca91" alt="Widget with language selector dropdown showing English and Hindi options" width="338" height="168" data-path="images/widget-full-language-selector.png" />

<img className="hidden dark:block" src="https://mintcdn.com/oration/30YYqnCV1Lr1_fNI/images/widget-full-language-selector.png?fit=max&auto=format&n=30YYqnCV1Lr1_fNI&q=85&s=5fe4bbd325837eb4e8baabaf6520ca91" alt="Widget with language selector dropdown showing English and Hindi options" width="338" height="168" data-path="images/widget-full-language-selector.png" />

**Agent selection logic:**

* If `agent-language-id-map` is provided, the map takes priority over `default-agent-id`
* If `default-agent-id` exists as a value in the map, it is pre-selected
* Otherwise the first entry in the map is used as the default

## Dynamic variables

Pass context to your agent using the `dynamic-variables` attribute. Values must be a JSON object of string key-value pairs.

```html theme={null}
<oration-widget
    public-key="pk_your_public_key_here"
    default-agent-id="asst_your_assistant_id_here"
    dynamic-variables='{"userId": "12345", "plan": "pro", "name": "John Doe"}'>
</oration-widget>
```

Variables are available in session metadata during the conversation. Common uses: user identification, current page context, subscription tier, A/B test variant.

### Programmatic updates

```javascript theme={null}
const widget = document.querySelector('oration-widget');

widget.setAttribute('dynamic-variables', JSON.stringify({
    userId: "67890",
    plan: "enterprise",
    currentPage: "/checkout"
}));
```

## Theme customization

Pass a JSON object to `theme` with any subset of the following keys. Missing keys fall back to defaults.

### Theme keys

| Key              | Role                                 |
| ---------------- | ------------------------------------ |
| `base`           | Primary background                   |
| `base_hover`     | Hover state background               |
| `base_active`    | Active/pressed state background      |
| `base_border`    | Border color                         |
| `base_subtle`    | Secondary / muted text               |
| `base_primary`   | Primary text                         |
| `base_error`     | Error states                         |
| `accent`         | Primary accent (buttons, highlights) |
| `accent_hover`   | Accent hover                         |
| `accent_active`  | Accent active/pressed                |
| `accent_border`  | Accent border                        |
| `accent_subtle`  | Muted accent elements                |
| `accent_primary` | Text on accent backgrounds           |

All values must be hex color strings.

```html theme={null}
<!-- Minimal: just override accent -->
<oration-widget
    public-key="pk_your_public_key_here"
    default-agent-id="asst_your_assistant_id_here"
    theme='{"accent": "#2563eb"}'>
</oration-widget>
```

```html theme={null}
<!-- Full theme -->
<oration-widget
    public-key="pk_your_public_key_here"
    default-agent-id="asst_your_assistant_id_here"
    theme='{
        "base": "#ffffff",
        "base_hover": "#f8fafc",
        "base_active": "#f1f5f9",
        "base_border": "#e2e8f0",
        "base_subtle": "#64748b",
        "base_primary": "#0f172a",
        "base_error": "#ef4444",
        "accent": "#2563eb",
        "accent_hover": "#1d4ed8",
        "accent_active": "#1e40af",
        "accent_border": "#1e3a8a",
        "accent_subtle": "#64748b",
        "accent_primary": "#ffffff"
    }'>
</oration-widget>
```

<img className="block dark:hidden" src="https://mintcdn.com/oration/30YYqnCV1Lr1_fNI/images/widget-full-custom-theme.png?fit=max&auto=format&n=30YYqnCV1Lr1_fNI&q=85&s=1cf50d2c6a0103c769e0eb2d5efb9547" alt="Widget with custom orange theme applied to chat interface" width="385" height="352" data-path="images/widget-full-custom-theme.png" />

<img className="hidden dark:block" src="https://mintcdn.com/oration/30YYqnCV1Lr1_fNI/images/widget-full-custom-theme.png?fit=max&auto=format&n=30YYqnCV1Lr1_fNI&q=85&s=1cf50d2c6a0103c769e0eb2d5efb9547" alt="Widget with custom orange theme applied to chat interface" width="385" height="352" data-path="images/widget-full-custom-theme.png" />

### Color mode

Use `color-mode` to force light or dark theme, or let the widget follow the user's system preference:

```html theme={null}
<oration-widget color-mode="dark" ...></oration-widget>
```

## External button trigger

Any element with `id="oration-conversation-trigger"` will open the widget when clicked. The trigger respects the widget's current state (no-op while connecting).

```html theme={null}
<button id="oration-conversation-trigger">Start AI Conversation</button>

<oration-widget
    public-key="pk_your_public_key_here"
    default-agent-id="asst_your_assistant_id_here">
</oration-widget>

<script src="https://unpkg.com/@oration/widget/dist/index.umd.js"></script>
```

If `conversation-type="both"`, the trigger shows the conversation type selector first.

## Terms acceptance

Show a consent gate before the first conversation. Acceptance is stored in `localStorage` and won't be shown again.

```html theme={null}
<oration-widget
    public-key="pk_your_public_key_here"
    default-agent-id="asst_your_assistant_id_here"
    require-terms-acceptance="true"
    terms-text="By continuing, you consent to the recording of this conversation.">
</oration-widget>
```

## Troubleshooting

**Widget not loading** — check the browser console, verify the script tag is present, and confirm your public key and agent ID are correct.

**Styling issues** — the widget uses Shadow DOM for style isolation. Custom styles must go through the `theme` attribute.

**No microphone access** — browser microphone permissions must be granted for voice conversations.

**Conversation fails** — verify the agent is configured and your workspace has sufficient credits.

<Warning>
  Your public key is visible in client-side code. Only use it on authorized domains. Never expose private API keys in the browser.
</Warning>

***

> Need help? Contact us at [support@oration.ai](mailto:support@oration.ai)
