app.waniwani.ai, so no backend proxy is required on your side.
Platform feature. The dashboard generates the embed snippet for your project. Open app.waniwani.ai to get yours, or read more about the Platform.
Quick start
- Open your project on app.waniwani.ai and copy the chat embed snippet from the project settings.
- Paste it into your site’s HTML, alongside a mount point where you want the chat to appear:
data-theme) or in CSS. Don’t hand-author the snippet — the channel ID is issued by the Platform and required for the embed to route correctly.
Modes
The embed renders in one of four modes, set withdata-mode on the <script> tag:
Use
inline when the chat is the page section. Use floating when it should be available everywhere without taking up layout space. Use composer for a search-box entry point inside your own layout (a hero, a help-center header, a row under a pricing table), where a full chat panel takes too much room and a corner bubble is too easy to miss. Use off when you want the tag’s non-chat behavior on a page that should look untouched: publishing tools to browsing agents, or host-page tracking, with nothing on screen.
composer mode the panel is appended to <body> rather than nested in your marker, so a transform or filter on an ancestor of the marker can’t drag the fixed panel out of position. Give the marker whatever width and margins your layout needs; data-height and the 500px inline default don’t apply. The conversation survives closing the panel: clicking the box again reopens it with the history intact.
Modal or sidebar
Infloating and composer mode, the first message opens the chat panel. data-panel-layout sets its shape. On the channel’s Integrate tab, the Chat panel field writes it into the snippet for you.
inline and off mode open no panel, so they ignore the attribute.
Give the sidebar a different width in CSS:
Let visitors dock the panel
data-panel-dockable="true" adds a button to the panel header that moves the open panel between the modal and the sidebar. The visitor chooses; data-panel-layout is only where it starts. The choice holds for as long as the page is open, so closing and reopening the panel brings it back where the visitor left it. Below 640px both layouts are the full-screen sheet, so the button changes nothing visible there until the window widens. Off by default: without the attribute the header is unchanged.
.ww-layout-toggle part and carries data-layout="modal" or "sidebar", so your data-css file can swap its icon per state. Its labels are the launcher.toSidebar and launcher.toModal wording keys. A click emits the panel.layout.changed event on onEvent. To turn the docked state into a smaller card instead of a full-height column, restyle it:
WaniwaniChat renders the inline chat, the composer and the floating bar with the same options. See Chat in React.
Sizing
Inline mode only. Infloating mode the panel sizes itself, and in composer mode the box is content-height inside a container you size.
The embed fills its container. Give the <div data-waniwani-embed> a definite size via CSS, or set data-height on the script tag:
500px tall. That default is written with :where(), so it carries no specificity and any rule you write beats it — including height: auto to let the chat grow with its content. A ResizeObserver mirrors the container’s max-height onto the embed so padding and borders are respected.
Overriding attributes
You can editdata-* attributes on the <script> tag to tweak behavior. Do it sparingly: an attribute set here permanently outranks the channel config the embed fetches from the dashboard (resolution order is dashboard → data-* → init()), so a title pinned on the tag can no longer be changed by whoever owns the channel.
Look and feel. Each one is covered in depth in Theming & customization:
Floating and composer modes:
Floating mode only. These shape the docked bar:
Composer mode only. The box sits in your layout, so its chrome is adjustable:
Composer variants
Every variant behaves the same: the first message opens the panel. Only the chrome differs.
Two, because a variant is a starting point rather than the ceiling. Radius, fill, border, shadow and the send button are CSS custom properties, so a fully rounded search bar is one declaration rather than a third variant. See Restyling with CSS.
Trigger instead of an input
data-composer-trigger="true" renders the box as a tap target: nothing is typed in the page, and a click opens the panel where the caret lands. For a host that wants one tap into the full chat and no in-page composing.
The box keeps its variant and whatever CSS you set on it — only the textarea is swapped for the trigger. It is the same swap On mobile applies automatically below 640px; this option applies it at every width.
Restyling with CSS
The box reads its fill, border, radius, shadow and send button from--ww-composer-* custom properties. Set them wherever you set the rest of the widget’s variables ([data-waniwani-embed] works, and so does :root); they inherit through the widget’s Shadow DOM. Anything you leave alone keeps the variant’s own value.
A flat box with a single rule under it:
.ww-composer-box, .ww-composer-field (the row holding the input and the send button), .ww-composer-input and .ww-composer-send. On the script tag the composer sits in a shadow root, so put these rules in the data-css file; in React, in a stylesheet loaded after @waniwani/chat/styles.css. An icon before the input and a larger, square send button:
On mobile
Below 640px the composer renders as a tap target rather than a live input, whatever variant you picked. One tap opens the panel, which is already a full-screen sheet at that width, and the visitor types there. This is the default because in-page typing on a phone is the worse half of the handoff: the soft keyboard covers the box, the first message opens a full-screen panel over it, and focus has to move mid-sentence. Going straight to the panel skips all of it. The box keeps its variant and whatever CSS you set on it; only the textarea is swapped out. Setdata-composer-mobile-trigger="false" to keep a real input at every width.
Section prompts on the floating bar
Withdata-dock-chips-trigger="scroll" (alone or in a list), the bar can show different chips for each part of a long page. The prompts come from your channel’s per-page prompts in the dashboard:
- An entry whose URL ends in a
#fragment, such ashttps://your.site/#pricing, belongs to the section with thatid. - When the visitor scrolls down and pauses, the bar reads the section at the centre of the viewport (the closest
<section>or element with anid) and shows the matching entry’s chips, once per section. - Anywhere else on the page, the bar uses the page’s entry without a fragment, else the first entry for the page, else the channel’s general suggestions.
Floating mode on phones
Below 640px the panel is a full-screen sheet. It fills the space above the soft keyboard and follows it as it opens and closes, so the header and the input stay in view. While the sheet is open your page can’t scroll behind it, and the visitor’s scroll position comes back when it closes. On a touch keyboard, Return adds a line and the send button sends. While the keyboard is up, the line under the input (the powered-by mark anddata-disclaimer) is hidden, so the input sits right on the keyboard. The line comes back when the keyboard closes.
Two behaviours can be switched on there:
- No keyboard on the first tap (
data-dock-readonly-mobile="true"). The bar’s input is read-only, so a tap opens the panel and the visitor types in it. By default the visitor types in the bar itself. - The back gesture closes the panel (
data-panel-history="true"). While the panel is open the widget holds one entry in the browser history, so back closes the panel instead of leaving the page. Closing the panel any other way removes the entry, and your page’s own history state is kept.
inline and composer mode the marker div collapses too, so a hidden page shows no empty box. In off mode there is nothing to gate.
Leave the wiring attributes (data-token, data-channel-id, data-api, the script src) as the dashboard generated them.
Beyond the attributes above, individual colors, fonts, sizes and shapes have no data-* equivalent: set --ww-* CSS variables instead, and restyle elements through their ww-* part classes in a data-css file. They inherit through the widget’s Shadow DOM, so declare them on [data-waniwani-embed] in inline or composer mode, or anywhere on the host page (:root works) in floating mode, where there is no container of your own. See Theming & customization for the full variable list and deep-customization recipes.
Full type definitions: EmbedConfig and ChatTheme.
Programmatic init
For runtime control (computing options dynamically, mounting on demand), drop thedata-token attribute from the script tag and call init() yourself. Keep the other wiring attributes from your dashboard snippet (data-channel-id, data-api), and call init() from the script’s onload:
embed.js is a small loader: it picks the newest @waniwani/chat 1.x and adds that bundle to the page. The script’s onload waits for the bundle, so window.WaniWani exists when your handler runs. DOMContentLoaded and window.addEventListener("load") on the tag do not wait for it and fire too early.
Leave data-token off the tag. With it, the chat starts by itself as soon as the bundle loads, and your init() call is ignored with an “already initialized” warning, along with every option you pass to it (onEvent included).
If your agent runs in the EU region (your snippet points at eu.app.waniwani.ai), pass the API to init() as well: api: "https://eu.app.waniwani.ai/api/mcp/chat".
If your page sets a Content Security Policy, add the API host (app.waniwani.ai, or eu.app.waniwani.ai for the EU region) to both connect-src and img-src. The chat sends its requests to that host, and the “powered by” logo is an image served from it.
From a tag manager
Google Tag Manager, CommandersAct and similar tools usually create the tag in JavaScript. Setonload on the element before you add it to the page:
onerror fires when the chat bundle fails to load (a blocked CDN, for example), and onload does not fire in that case. Keep the loader URL rather than pointing at a pinned cdn.jsdelivr.net version: the loader picks up new releases within minutes, and a pinned version never does.
init() returns an instance that carries the same methods as the window.WaniWani.chat global, listed in Control the chat from your page.
init() also accepts an onEvent callback that mirrors chat lifecycle events (opens, messages, errors, link clicks) into your own analytics — Amplitude, Segment, gtag — with your page’s identity attached automatically. See Widget events (onEvent).
Control the chat from your page
Once the script has loaded,window.WaniWani.chat drives the chat from anywhere on your page. Call it from your own buttons, links or router events to open the panel without going through the chat bar, or to ask a question on the visitor’s behalf.
defer, so the optional chaining (?.) keeps a click that lands before it has run from throwing.
Calling these methods doesn’t bypass the per-URL show/hide rules set in the dashboard. On a page the rules hide,
open() and sendMessage() show nothing, so the rules have to show the chat on every page that carries one of your buttons.sendMessage() to a visitor’s click, which lands after the load, rather than calling it from a page-load script.
To react when the visitor opens or closes the panel themselves (hiding your own button while the panel is up, say), listen for chat.opened and chat.closed in the onEvent callback. See Widget events (onEvent).
restart() and copyConversation() let you wire your own “Start over” and “Copy” buttons, with the same effect as the header menu’s entries (data-menu). The menu fires the same conversation.restarted and conversation.copied events.
The page the visitor is on
From SDK 0.24.1, the chat sends the address of the page the visitor is on with every message, and Waniwani tells your agent about it. Someone who asks “how much would this cost me?” on your pricing page gets an answer about that page without having to say where they are. There is nothing to switch on. If you load a pinned SDK bundle yourself, use@waniwani/sdk 0.24.1 or later.
The agent gets the address and nothing else from the page. It doesn’t see the page’s text, its forms, or what the visitor typed into them. So tell the agent what your pages are: a line in its system prompt such as “/simulator is the loan simulator, /rates lists today’s rates”, or the pages’ content in its knowledge base.
- The full address is sent, including everything after
?and#. Keep personal data such as email addresses out of your URLs. - Only web pages count. An address that doesn’t start with
http://orhttps://, or is longer than 2,048 characters, is dropped, and the agent is told nothing about the page. - It follows single-page apps. The address is read when each message is sent, so it stays right after in-app navigation.
Link visitors to your analytics
By default the embed mints its own anonymous visitor id, a stable opaque value persisted in the browser’slocalStorage. It rides on every chat request and tracking event, so a visit is attributable before the first message mints a session (see Sessions).
If your site already tracks visitors with PostHog, Amplitude, Segment, or a first-party cookie, override that id with your own. Waniwani then correlates its sessions and events to the same visitor you see in your analytics, and your server-side MCP tools and flows read the id back as context.waniwani.visitorId, so they can send events straight to the same analytics tool the id came from.
There are three ways to set it. Pick the one that matches when your id is available.
If you know the id up front
Set it declaratively on the script tag:init() when you initialize programmatically. init() accepts a string or a resolver (sync or async), so you can read the id inline:
If the id resolves asynchronously (the common case)
Analytics SDKs usually assign a distinct id only after they bootstrap, so read it when it’s ready and hand it to the widget.setVisitorId() is safe to call at any time, before or after init(), and the new id applies to the next chat request and tracking event:
window.WaniWani.chat.getVisitorId().
The visitor id identifies a device / browser, not a signed-in account. When a visitor logs in, keep the visitor id and additionally call
identify() with your account id, so anonymous and known activity stitch together.Agent traffic beacon
The embed can tell your site’s agent traffic when an AI agent drives a browser on the page. It is off by default while we measure it; turn it on withdata-agent-beacon="on" or init({ agentBeacon: true }). It runs in every mode, off included, so you can use it with no chat on the page.
The beacon watches for signs of automation: the WebDriver flag, a headless browser, the globals that Playwright, Selenium and ChromeDriver leave, and input no person makes (script-made events, a click with no mouse movement, a pointer that jumps to its target). Only when one of these fires, it sends one small report to Waniwani with:
- the names of the signals it saw
- the page URL without its query string, and the referrer’s origin and path
- the time since the page started loading
Self-hosting the JS bundle
If you’d rather not load from a CDN, pin a specific@waniwani/chat version and serve the bundled file yourself. The data-* attributes still come from the dashboard snippet — you’re only swapping where embed.js is served from:
How it works
- The script reads its own
data-*attributes (token, channel ID, mode, theming, content overrides). - On
DOMContentLoaded(or immediately, if the DOM is already ready), it mounts the chat via Shadow DOM — inside[data-waniwani-embed]ininlineandcomposermode, or in its own anchored container infloatingmode.composermode adds a second,<body>-level container for the panel. - The chat calls
app.waniwani.ai/api/mcp/chatwith the project token and streams responses back through Server-Sent Events. - Conversation history lives only in memory by default; set
data-enable-thread-historyto persist threads in IndexedDB on the user’s device.