Skip to main content
The Web Widget channel puts a chat launcher on any page of your site with a one-line script tag. Visitors chat with your bot in a panel that matches your light or dark theme, keep several conversations, and see unread badges. Your backend can tell the widget who the visitor is with a signed token, and can attach per-user MCP servers to every new conversation so an AI agent can act on their behalf.
Want the complete flow — web widget, AI agent and your product’s own MCP server — set up end to end? Follow the guide Embed an AI assistant backed by your product’s MCP server. It is written for an AI agent to execute and flags every step that needs a human.

Overview

A web widget channel gives you:
  • Embeddable launcher: a script tag that renders a launcher button and chat panel on your pages
  • Visitor identity: a short-lived HS256 token your backend signs so conversations are bound to your user ids
  • Access control: anonymous visitors on or off, and an allow-list of origins the widget may load from
  • Multiple conversations: visitors start, resume and close conversations; unread counts show on the launcher
  • Theming: a light and a dark accent color, an optional header color per mode, following your site’s theme automatically
  • Realtime delivery: an optional WebSocket that pushes replies and typing the moment they happen, with polling as the automatic fallback (see Realtime delivery)
  • MCP servers for conversations: a webhook your backend answers with the MCP servers to attach to each new conversation
The widget talks to a public, rate-limited API on the platform. Your pages never need to call that API directly; the script handles it.

Create the channel

1

Open your bot's channels

In the dashboard, open your bot and click Channels, then Add channel.
2

Choose Web Widget

Select Web Widget in the platform picker.
3

Name and style it

Fill in the form:
4

Decide who can chat

  • Allow anonymous visitors — leave off when your site will identify users with a signed token; turn it on for public sites where anyone may chat.
  • Allowed origins — one per line, such as https://www.example.com or https://*.example.com. Leave empty to allow any site.
5

Save

Click Create Web Widget. You land on the channel page with the embed snippet, the signing secret and, if the bot has no AI agent yet, the Power this chat with an AI agent section already open.

Embed it on your site

Copy the snippet from the channel page and paste it before the closing </body> tag on every page where the launcher should appear:
The widget key is shown under the snippet on the channel page. It is public — it only identifies the channel.

Per-page overrides

Data attributes on the script tag override the channel settings for that page:

Programmatic setup

Instead of data attributes you can load the script and call ChatbotWidget.init() yourself. This is the right choice for single-page apps that need to refresh identity tokens:

JavaScript API

The widget also fires events on window so your page can react without polling it — see Events for your own UI below.

Events for your own UI

Build a badge in your header, a “the assistant is working” spinner or an activity log around the widget by listening for chatbot-widget:* events on window. Every event is a CustomEvent; the payload is event.detail. They fire while the panel is open and while it is closed, on both delivery modes (the WebSocket pushes replies and typing for every conversation; on polling the widget’s background list poll carries the same, every 3–10 seconds, see Realtime delivery). On polling, a hidden tab with the notification sound off pauses that poll and catches up when the tab is visible again. What “typing” means. typing: true is the same state the widget’s own bouncing dots and Typing… status show: the bot has signalled it is composing (your integration’s typing indicator, the agent loop’s thinking) or the visitor just sent a message and the reply is still awaited (that wait ends when the reply lands, or after 90 seconds). A bot that never signals typing still produces a true/false pair around every reply to the visitor’s own messages. Typing signals expire on their own after a few seconds unless the bot refreshes them, so a lost “stopped” never leaves your indicator on. ChatbotWidget.typing() returns the current state (an array of conversation ids) whenever you need it outside an event, e.g. on page load.
Older events keep their shapes: chatbot-widget:unread fires on every change of the total (not on every reply — a reply in the conversation on screen is read at once and leaves the total alone, which is why chatbot-widget:message exists), and chatbot-widget:notify is tied to the notification ping, so it stays quiet while the visitor looks at the chat or when the sound is off.

Open a conversation by id

Deep-link a user into one of their conversations — from an order page, a notification email, a support ticket — with:
Signature. ChatbotWidget.openConversation(conversationId: string): Promise<OpenResult>. conversationId is the conversation’s UUID: the one in the admin conversation URL, in the conversation.id field of the webhook payloads and in the Conversations API. The promise never rejects. Who may open what. Access follows the widget’s identity: the sub of the user token, or the anonymous visitor id when the widget allows anonymous visitors. A conversation can only be opened by the identity that owns it, on the widget key that created it. Event. Every outcome is also fired as chatbot-widget:open-conversation on window, so you can react without holding on to the promise. event.detail is the result above plus source: 'api' for your call, 'list' when the visitor tapped a conversation in the widget’s own list.
When you can call it. Any time after widget.js has executed. Calls made before the widget has finished mounting (it fetches its configuration first) are queued and run once it has; ChatbotWidget.ready() resolves at that moment. If your code may run before the script tag itself has loaded, call it from the script’s load event:

Identify your users

Without a token the widget treats the visitor as anonymous, which only works while Allow anonymous visitors is on. To bind conversations to your own user accounts, your backend signs a JSON Web Token (HS256) with the channel’s signing secret (shown on the channel page; keep it server-side) and hands it to the page via data-user-token, userToken or getUserToken.

Token claims

Only alg: HS256 is accepted. Tokens signed with none or any other algorithm are rejected. An expired token returns 401 with code: token_expired; a bad one code: token_invalid; a missing one on a channel without anonymous access code: token_required. The widget calls getUserToken again on token_expired, so long-lived sessions keep working.
Regenerate on the channel page rotates the signing secret. Every token signed with the old secret stops working immediately, so update your backend first and rotate right after.

Conversations and unread badges

Each identified user can hold several conversations on a widget. The widget shows a list (open conversations first, past ones collapsed), lets the visitor start a new one or resume an old one, and marks a conversation closed when they end it — closed conversations are read-only, and sending into one returns 409 with code: conversation_closed.

Naming conversations

A conversation is listed under the first message the visitor sent until they give it a name. The pencil button in the panel header opens a small form over the composer; the name is free-form text (up to 80 characters, trimmed, line breaks collapsed), replaces the first-message title in the list and the sidebar and takes the place of the widget title in the header while that conversation is open. Past (closed) conversations can be named too. Saving a blank name clears it, so the default title is back. The name is stored on the conversation, so it follows the visitor across devices and page loads and shows on the conversation page in the dashboard. Your page can set it as well with ChatbotWidget.renameConversation(name) and hear about every change through the chatbot-widget:conversation-renamed event on window (detail: { conversationId, name }, name is null when it was cleared). Channels with realtime delivery push the new name to the visitor’s other tabs the moment it is saved.

Starring conversations

The list orders conversations by their latest activity, so a conversation the visitor keeps coming back to can slip down as newer ones get replies. The star button in the panel header pins the open conversation to the top: starred conversations always sit above every unstarred one, newest activity first inside each group, and each shows a small star before its title. Tapping the star again takes it off. Starring is the visitor’s own: a conversation belongs to one identified user, so nobody else sees or shares the star. Ending a conversation always takes its star off — only open conversations are pinned, and past conversations never show a star button. The star is stored on the conversation, so it follows the visitor across devices and page loads, and the conversation page in the dashboard shows when it was starred. Your page can star and unstar the conversation on screen with ChatbotWidget.starConversation() and ChatbotWidget.unstarConversation() (both resolve with { status: 'starred' | 'unstarred' | 'error', conversationId, starred }; starring an ended conversation answers error: 'conversation_closed') and hear about every change through the chatbot-widget:conversation-starred event on window (detail: { conversationId, starred, starredAt }). Channels with realtime delivery reorder the visitor’s other tabs the moment a star changes.

Archiving conversations from the list

A conversation can be ended straight from the list, without opening it: swiping an open conversation’s row to the left (or dragging it with the mouse) slides it over and reveals a red Archive button at its right edge. Tapping Archive ends that conversation the way End conversation in the chat view does — it moves under Past conversations, becomes read-only and loses its star — and the list stays on screen. A short swipe snaps back, a tap on the revealed row or anywhere else in the list puts the button away (only a tap on another row opens that one), swiping the row back to the right closes it too, and one row shows its button at a time. Past conversations have no Archive button. There is no confirmation step: the swipe and the tap are the two deliberate steps, and a conversation that was ended cannot be reopened, so a visitor who wants to keep one just lets the row snap back. Your page can do the same by id with ChatbotWidget.closeConversation(id) (resolves with { status: 'closed' | 'error', conversationId, closedAt }, closed also for a conversation that had already ended) and hears about every conversation ended in this tab — from the chat view, the list or your own call — through the chatbot-widget:conversation-closed event on window (detail: { conversationId, closedAt, source }, source is 'chat', 'list' or 'api'). Channels with realtime delivery move the conversation in the visitor’s other tabs the moment it ends. Unread bot replies are counted per conversation. The launcher shows the total while the panel is closed, the list shows a count per conversation, and viewing a conversation clears its count. Counts are cached in the browser so the badge is right on the next page load before the first poll. Your page can show its own badge from ChatbotWidget.unreadCount() and the chatbot-widget:unread / chatbot-widget:message events, and a progress indicator from chatbot-widget:typing — see Events for your own UI. In the dashboard, every widget conversation shows the identified user (id, name, email, attributes), the page it was started on, the name the visitor gave it, whether they starred it and whether it is closed. New channels push replies, typing and unread counts over a WebSocket the moment they happen and fall back to polling by themselves whenever a socket cannot connect; older channels poll until you tick Push replies over a WebSocket under Delivery on the channel page. Details, host-page controls and the connection-count note are on Realtime delivery.

Message formatting

Messages are written in Markdown and the widget renders it, in every bubble, the visitor’s and the bot’s alike. Nothing a visitor or a bot sends is ever treated as HTML: the text is escaped before any formatting is applied, so a <script> tag or an onerror attribute in a message is shown as those characters, never run. The widget has no Markdown library and no sanitizer to keep patched; its renderer can only produce the handful of tags listed here, and a link is only made clickable when its address is a web page (http:// or https://), an email address (mailto:) or a phone number (tel:). A single newline inside a paragraph is a line break, as chat readers expect; a blank line starts a new paragraph. Web links open in a new tab with rel="noopener noreferrer"; a www. host gets https://; mailto: and tel: links carry no target, so they hand off to the mail or phone app without leaving a blank tab behind (a mailto: address needs an @, a tel: number is digits with + - . ( ), anything else stays text, and a bare phone number such as “call 555-0100” is never linked, only a tel: one); punctuation right after a URL and the closing bracket of a parenthesised one stay outside the link, and URLs inside `code` stay as they are. Images are not loaded: ![logo](https://example.com/logo.png) becomes a link to the image, so a message can never make a visitor’s browser fetch a URL of its choosing. Indented (four-space) code blocks are not supported — use fences. Plain-text messages look exactly as before. The built-in echo bot’s system prompt tells it what renders. Bots on an agent-loop or webhook integration get the same guidance from your system prompt: Markdown is rendered, prefer short paragraphs and lists, keep tables small, and never send raw HTML.

Full screen on tablets and desktops

Tick Let visitors expand the chat to full screen under Layout on the channel page and the chat header gets an expand button on screens 768px and wider (tablets and desktops). Full screen fills the browser window: the visitor’s conversations are listed on the left third, scrollable, with a New conversation button on top, and the open conversation takes the right two thirds. Everything else works as in the compact panel — unread counts, ending a conversation, typing, the notification ping. The panel reopens in the size the visitor closed it in: close it in full screen and the next open — on this page or the next one — is full screen again, collapse first and it comes back compact. The choice is remembered in the visitor’s browser (localStorage, next to their conversations, per signed-in user); a first-time visitor or one who cleared site data gets the compact panel. When the window shrinks below 768px while expanded, the panel drops back to compact and the button hides; if the window grows back while the panel is still open, full screen returns. Phones keep today’s full-height panel and never show the button. With the setting off nothing changes for anyone. Your page can hide the button per page with data-fullscreen="off" on the embed snippet or ChatbotWidget.init({ fullscreen: false }) (and offer it on a page even when the channel does not with "on" / true), switch the layout with ChatbotWidget.expand() and ChatbotWidget.collapse() while the panel is open, read it with ChatbotWidget.layout(), and listen for chatbot-widget:layout on window (event.detail.layout is 'compact' or 'fullscreen') to hide a sticky header of your own while the chat fills the screen.

Light and dark mode

The widget ships both themes and you pick an accent per mode under Colors; text on the accent switches between white and near-black automatically for contrast. The panel header can have its own background per mode with Header color (light mode) and Header color (dark mode): a #rrggbb value, or leave it empty (the Use accent button clears it) to keep the header on the accent, which is what every widget does until you set one. Text and buttons in the header pick white or near-black against that color the same way. Per page, data-header-color and data-dark-header-color on the embed snippet (or headerColor / darkHeaderColor in ChatbotWidget.init()) override them. With Color scheme on Auto the widget follows your site: a dark or light class or a data-theme attribute on <html>, a color-scheme pinned to one mode, and otherwise the visitor’s system preference. It also reacts when your own theme toggle changes those. Force a mode per page with data-color-scheme="dark" or at runtime with ChatbotWidget.setColorScheme(). The Open preview page button on the channel page shows the widget on a stand-in site with a Light site / Dark site toggle.

MCP servers for conversations

Expand MCP servers for conversations on the channel page to name a webhook on your backend. When a visitor starts a new conversation, the platform POSTs a signed conversation.started payload describing the visitor, and your backend answers with the MCP servers (URL plus auth headers) to attach to that conversation — a CRM, an orders API, anything scoped to that user. An agentic loop on the bot can then call those tools from the very first message.
  • Timeout and retry: 10 seconds, retried once. A failing webhook never blocks the conversation; it simply starts without extra servers.
  • Signature: X-Chatbot-Timestamp plus X-Chatbot-Signature: v1=<hex HMAC-SHA256 of "timestamp.body"> with the webhook secret minted the first time you save a URL. Reject stale timestamps.
  • Response: HTTP 200 with { "mcp_servers": [ { "name", "url", "headers": [ { "key", "value" } ] } ] }. Up to 20 servers; an empty list is fine.
  • Preferences (optional): the same response may add "preferences": [ "User's timezone for dates and times: America/Chicago", … ], up to 20 strings of at most 1000 characters, which pre-fill the conversation’s preferences so the agent knows them from its first reply. Texts already recorded are left alone and nothing is ever removed; the list is ignored while the bot’s Preferences switch is off. Details and examples: Embed an AI assistant backed by your product’s MCP server → Preferences.
  • Skills (optional): the response may also add "skills": [ { "name", "summary", "content" } ], up to 20 processes saved as skills of the person behind the conversation. Names they do not have yet are created; a skill they already have is never overwritten and one they deleted is not brought back. Ignored while the bot’s Skills switch is off. Details: Embed an AI assistant → Skills.
  • Static headers: optional headers sent with every request, for example an API key your endpoint expects.
  • Send test request fires a signed conversation.test with the saved URL and shows what your webhook answered.
  • Built-in test webhook: no backend yet? Click Use built-in test webhook. The platform’s own endpoint answers with the Widget Identity MCP server (whoami, get-user-attribute), so you can ask the bot “what is my email address?” and watch the whole pipeline work.
The admin conversation page has an MCP servers tab showing the discovery outcome and a Re-run discovery button.

Skills

With Skills on for the bot (Behavior → Agent Context), a widget user can teach the agent a process once and ask for it in any later conversation. Skills follow the identity: the sub of the identity token, or the anonymous visitor id of the browser. A visitor links their Telegram or Slack account by sending /link CODE in the chat, or your page calls ChatbotWidget.claimLinkCode(code) (resolves { status: 'linked' | 'error', outcome, message, skillsNowAvailable, renamed }, fires chatbot-widget:linked). See Skills. The full contract with payload and verification examples is in the guide: Embed an AI assistant backed by your product’s MCP server.

Power it with an AI agent

The channel page opens with Power this chat with an AI agent. Enter a system prompt, pick a tool-capable model, paste your team’s OpenRouter API key if it has none, choose the Tools for each visitor option (built-in test server, your webhook URL, or none), leave Only the agent answers ticked and click Launch agent. The platform creates an agentic-loop integration on the bot (or updates the one it created before), switches off competing integrations and points MCP discovery where you asked. The Test your web chat panel below it then lists what is still missing and lets you chat with the real widget as yourself.

Troubleshooting

Next steps

Embed an AI assistant with MCP

Agent-executable guide from empty account to a live assistant using your product’s tools

Agentic Loops

How the agent reasons and calls tools

Realtime delivery

Push replies over a WebSocket, with polling as the fallback

Other channels

Telegram and Slack