Embed the web widget
Put your agent on any website with one script tag — bubble, window, and full-screen modes included.
Basic embed
<script src="https://chat.agent4.io/ui/embed.js"
data-token="YOUR_SHARE_TOKEN" async></script>The loader injects a floating chat bubble (bottom-right) that expands into a window or full screen. The iframe points at the platform origin, so your site needs no CORS setup.
Options
| Attribute | Effect |
|---|---|
data-token | Required. The share token from the console. |
data-color | Accent color for the widget header/bubble. |
data-position="left" | Docks the bubble bottom-left instead of bottom-right. |
Keyboard: Ctrl/⌘ + Shift + F cycles bubble → window → full screen.
Domain allow-list
Each share carries an allowed_domains list. The platform enforces it with a frame-ancestors CSP,
so the widget only renders inside the sites you listed. Configure it on the share in the console.
Authentication modes
A share runs in one of three modes:
- Anonymous — visitors chat without an account; each browser gets its own space.
- Account login — visitors sign in with a platform end-user account; history and memory follow them across devices.
- Host session (HMAC) — your backend tells the widget who the user is, so your logged-in users are recognized without a second login:
<script src="https://chat.agent4.io/ui/embed.js"
data-token="YOUR_SHARE_TOKEN"
data-uid="user-42"
data-ts="1767139200"
data-sig="HMAC_SHA256(secret, uid + ts)"
async></script>Your server computes data-sig with the share's signing secret; the platform verifies it and maps
user-42 to a stable end-user identity.
Standalone page
Every share is also reachable as a full page at https://chat.agent4.io/s/YOUR_SHARE_TOKEN — useful
for QR codes, email links, or ad landing pages when you don't control the hosting site.