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
| Attribute | What it does |
|---|---|
data-bot | the bot's public id (required) |
data-host | the workspace, when the script is loaded from somewhere else |
data-user-url | your server's endpoint that says who the signed-in user is (below) |
data-context | what 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-brand | the brand color before the bot's own style loads |
data-auth-token | for 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:
- Add
data-user-urlwith an endpoint on your own server, likedata-user-url="/api/oalo-chat-session". The widget calls it with the page's cookies each time it connects. - 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_TOKENcan do it. Any other Sync API token needs thechatscope (oalo tokens create --name <what it is> --scope chat). The call is refused from a browser: the token must stay on your server. external_refis required: your app's own id for the user.email,nameandphonefill 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_refreaches 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 overdata-context).
Other ways to identify the user
- Oalo's own sign-in (an app Oalo built):
data-auth-tokenwith the user's session token. - A Firebase-style ID token, verified by Oalo (the bot's Auth settings):
POST /api/v1/chat/tokenexchanges 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/sessionsanswers 409bot_not_published). - The page's domain isn't in Allowed domains once the list has any entry.
- Calling
/api/chat/v1/sessionsfrom 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.
Call a workflow from your app's server like a function, POST /api/workflows/v1/<name>/run, and get back what its Output step returns.
Start workflows from your app: send an app.* event to POST /api/events/v1, or turn on row events so table changes fire data.<table>.created.
The six kinds of credential in Oalo, what each one is for, how to create it, and which ones are safe to put in an app.
Give an app its API keys and settings with oalo env, per env: what is secret, what each kind of app gets, its own token and database, and when changes apply.
Sign up, install the CLI, and deploy your repo in a few minutes.