The chat widget on your site or app

Put a bot on any web page with one script tag, anonymous or signed in as your app's own user through POST /api/chat/v1/sessions.

One script tag puts a bot on any web page: a chat bubble in the corner, or the whole page as the chat. It has the bot's persona, knowledge, flows, widgets, guardrails and cost tracking, and its conversations land in the inbox like any other. The snippet is in the bot's Embed tab:

<script src="https://<workspace>.oalo.ai/chat-widget.js"
        data-bot="bot_..." data-host="https://<workspace>.oalo.ai" defer></script>
  • The bot must be published. A draft can't be embedded.
  • Allowed domains (Embed tab): the pages that may load the chat. Empty allows any site, which is fine while you try it; list your domains before you share it. Each entry matches one host exactly (app.example.com), so list every host; a bare * allows any.

Attributes

AttributeWhat it does
data-botthe bot's public id (required)
data-hostthe workspace, when the script is loaded from somewhere else
data-user-urlyour server's endpoint that says who the signed-in user is (below)
data-contextwhat the user is doing ("On the pricing page"), shown to the bot as session context. Untrusted: never use it to decide what someone may see
data-open="1"open the chat on load instead of waiting for a tap
data-display="page"the whole page is the chat: no bubble, no close button
data-brandthe brand color before the bot's own style loads
data-auth-tokenfor an app that uses Oalo's own sign-in: the user's session token

Keeping the conversation across pages

By default a visitor's chat lasts while the page is open (a reload within half an hour, or an idle tab, comes back to it). Turn on keep conversations (embed_config.persist) and the chat follows them from page to page and when they come back later: the widget keeps a key to their conversation in the browser, for 30 days unless you set persist_days (1 to 90). A conversation that was closed starts fresh. Mention it in your privacy notice: the browser stores that key, though nothing that identifies the person.

Cards and buttons

Turn on cards (embed_config.cards) and the bot can show cards in the chat: a title, image, badge, price, bullet points and up to 3 buttons each, stacked or side by side to swipe, or a row of buttons on its own. A button opens a link or answers for the visitor, like a quick reply. Use them for plans or products to compare, the page an answer came from, or a confirmation. On WhatsApp, Instagram, SMS and email the same content goes as text with links.

Signed in as your app's user

Without anything else, every visitor is anonymous: each page load is a new visitor, and the bot knows nothing about them. When your app has its own sign-in (sessions, Auth0, Clerk, anything), your server can vouch for the user so the chat knows who they are:

  1. Add data-user-url with an endpoint on your own server, like data-user-url="/api/oalo-chat-session". The widget calls it with the page's cookies each time it connects.
  2. That endpoint checks the user is signed in (your own session), asks Oalo for a user token, and answers with it. Signed out, it answers 401 and the chat stays anonymous.

With oalo typegen, the endpoint is a few lines:

import { createChatSession } from "./oalo.generated";

app.get("/api/oalo-chat-session", async (req, res) => {
  if (!req.user) return res.status(401).end();
  res.json(await createChatSession("bot_...", { external_ref: req.user.id, email: req.user.email, name: req.user.name },
    { context: `Plan: ${req.user.plan}` }));
});

Without it, the endpoint posts to Oalo itself:

POST /api/chat/v1/sessions
Authorization: Bearer $OALO_SYNC_TOKEN
{"bot": "bot_...", "user": {"external_ref": "42", "email": "ana@example.com", "name": "Ana"}, "context": "Plan: pro"}
-> 201 {"user_token": "...", "expires_at": "...", "bot": "bot_..."}

and answers the widget with that JSON.

  • The token: a server app's own OALO_SYNC_TOKEN can do it. Any other Sync API token needs the chat scope (oalo tokens create --name <what it is> --scope chat). The call is refused from a browser: the token must stay on your server.
  • external_ref is required: your app's own id for the user. email, name and phone fill in their contact.
  • The user token lasts an hour and works only for that bot. The widget fetches a fresh one when it connects again.

What the user gets:

  • One thread on any device. The conversation is keyed by your user's id, so their phone and laptop share it, and a returning user sees what was said. A Conversations API call with the same external_ref reaches the same thread.
  • Their contact. It's found or made from the id, email and phone, as app events do it, so the inbox, the CRM and workflows know who it is.
  • Your context, from context, shown to the bot as session context (it wins over data-context).

Other ways to identify the user

  • Oalo's own sign-in (an app Oalo built): data-auth-token with the user's session token.
  • A Firebase-style ID token, verified by Oalo (the bot's Auth settings): POST /api/v1/chat/token exchanges it for a Conversations API token, for apps that drive the bot over HTTP instead of the widget.

Limits against abuse

A chat on a public page can be scripted, so Oalo limits it on its own. A real visitor never reaches these:

  • 30 new chats an hour from one IP address.
  • 300 messages an hour from one IP address, across all its chats.
  • 12 messages a minute and 200 a day in one chat.

Past a limit, the visitor sees a short note to try again later, and nothing reaches the AI, so it costs nothing.

You can set these per bot, under Limits in the bot's API access section, or with oalo bots settings <bot> set ...:

  • Messages / user / day (daily_message_cap_per_user): per visitor.
  • Web chat messages / IP / hour (web_ip_messages_per_hour): replaces the 300. Lower it when each visitor has their own connection; raise it where many share one, like a gym's or a shop's wifi.
  • Hard cap ($/day) (hard_daily_cap_cents): the bot stops answering for the day once its AI spend passes it. This one holds even against someone switching IP addresses, so set it on any public bot. A soft cap warns you first.

Common mistakes

  • The bot isn't published, so the widget shows nothing (and /api/chat/v1/sessions answers 409 bot_not_published).
  • The page's domain isn't in Allowed domains once the list has any entry.
  • Calling /api/chat/v1/sessions from the browser. It's refused. Call your own endpoint, and let it call Oalo.
  • A user id that changes (an email that can be edited) splits a user's history. Use the id your app never changes.
Related
Try it on your own Base

Sign up, install the CLI, and deploy your repo in a few minutes.

bring your repo