Website widget embed
Install the Zoie chat and voice widget with its script tag: the public widget key, where to place the snippet, what loads and when, Allowed Domains, the Content Security Policy it needs, single-page apps, rate limits and troubleshooting.
The website widget is a floating launcher that opens a chat or a live voice call with your AI agent. You add it with one script tag. Everything it shows and does, from the agent and greeting to the colours and lead form, is configured in the widget editor and loaded fresh on every page view. See Widgets overview.
Install
- In Zoie, open Marketing → Widgets, select the widget and click Publish.
- Copy the snippet from Add Widget to Your Website.
- Paste it into the HTML of every page that should show the widget, for example in your site’s shared footer template. Then publish your site.
The snippet looks like this, with your own widget key:
<!-- Zoie Widget -->
<script
src="https://us.zoie.ai/widget-bundle.js"
data-widget-id="3f6b2a9e-1c4d-4e8f-9a7b-5d2c1e0f4a6b"
defer>
</script>
The dialog’s own placement advice, site builders and tag managers are covered in Publishing and installing the widget. Ready-made variants for frameworks and consent banners are in Installation snippets.
Where the tag can go
- Anywhere in the page. The script starts as soon as the document is ready, whether it runs in
<head>or at the end of<body>, withdefer, withasyncor added later by JavaScript. Keepdeferso it doesn’t hold up your page. - Once per page. If the tag appears twice, for example in your theme and again through a tag manager, the widget is set up twice in the same container. Pick one place.
- The real page, not a frame. The widget attaches to the
document.bodyof the frame it runs in. Site builders that run “custom code” inside an iframe trap it in that frame. Use the builder’s site-wide header or footer code setting instead.
The widget key
data-widget-id carries the widget’s public key, a random UUID that Zoie creates with every widget. It’s the only identifier in the snippet. The AI agent isn’t in the snippet: Zoie looks up the widget’s current agent on every page load, so you can switch agents in the editor without touching your site.
- Embeds that carry the widget’s older numeric ID still work.
- Embeds that carry only
data-agent-idalso still work, but they load whichever of that agent’s widgets was updated most recently. Replace them with the current snippet. - The key isn’t a secret. It’s visible in your page source, so use Allowed Domains to control where it runs.
What happens on a page view
- The bundle loads and logs
[ZoieWidget] build: …to the console, followed by the build name and version. - It looks up the widget by its key. Zoie checks the widget is switched on and the page’s domain is allowed, then returns the widget’s settings and current agent.
- It checks that AI is switched on for the business and for the widget channel. If not, no launcher is drawn.
- It draws the launcher, and the greeting bubble if one is set. If the visitor already had the chat open on the previous page, it reopens.
- Chat with Agent starts or resumes a chat session and opens a WebSocket for live replies. Speak with Agent asks for the microphone and joins a voice call.
On screens 640 px wide or narrower, the open widget fills the screen.
Allowed domains and the Publish dialog
The Allowed Domains box on the Setup tab limits where the widget runs. With the box empty, it runs on any site that has the snippet. Once it has entries, the widget refuses to load, start a chat, send a message or start a call from any other site. The matching rules, including how www. and *. behave, are in Configuration.
The Websites list in the Publish dialog shows the allowed domains. When the box is empty, it shows the sites the widget has actually been seen on. Turning a site’s toggle off blocks the widget there, even when the allowlist is empty.
Each site in the list can be verified. Zoie fetches the site’s home page and looks for the script and the widget key in its HTML. A widget added by a tag manager or by a single-page app at runtime isn’t in that HTML, so the check can say it isn’t installed when it is. The widget is detected anyway as soon as a real page loads it.
Content Security Policy
If your site sends a Content-Security-Policy header, it must allow the sources below. The widget doesn’t support CSP nonces.
| Directive | Allow | Used for |
|---|---|---|
script-src | https://us.zoie.ai | The bundle itself. |
connect-src | https://api-us.zoie.ai wss://api-us.zoie.ai | Widget settings, chat requests, and the WebSocket that delivers replies. |
connect-src | https://*.livekit.cloud wss://*.livekit.cloud | Voice calls. |
connect-src | https://us.i.posthog.com | Anonymous product analytics. Optional: blocking it doesn’t affect the widget. |
style-src | 'unsafe-inline' https://fonts.googleapis.com | The widget adds its own <style> elements, and loads its font’s stylesheet. |
font-src | https://fonts.gstatic.com | The Plus Jakarta Sans font files. If they’re blocked, the widget falls back to the system font. |
img-src | https://api-us.zoie.ai data: | Your business icon and launcher icon, and the widget’s built-in icons. A logo stored on another host needs that host too, which is why img-src https: data: is the simplest rule. |
Content-Security-Policy: script-src 'self' https://us.zoie.ai; connect-src 'self' https://api-us.zoie.ai wss://api-us.zoie.ai https://*.livekit.cloud wss://*.livekit.cloud https://us.i.posthog.com; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src 'self' https://fonts.gstatic.com; img-src 'self' https: data:
Merge these sources into your existing policy rather than replacing it.
Voice calls and the microphone
Voice runs in your page, so the browser asks for the microphone on behalf of your site. For it to work:
- the page must be served over HTTPS,
- your site must not send
Permissions-Policy: microphone=(). Allow at leastmicrophone=(self).
If Speak with Agent isn’t wanted at all, switch voice off on the widget’s Interaction tab. See Interaction settings.
Single-page apps
The widget mounts once on document.body and stays mounted through client-side route changes. It doesn’t watch the URL. For React, Next.js, Vue and similar apps:
- Load the script once, from your root layout or app shell, and guard it so a re-render doesn’t add a second tag. See React and Next.js.
- Don’t remove
#static-widget-container. A page-transition library that swaps the whole<body>removes the widget. Keep the container outside the swapped region, or use full page loads. - Greetings run once per full page load. The greeting bubble’s timing and the targeted greetings for campaign, returning and high-intent visitors are evaluated when the widget first loads, not on each route change. See Welcome greeting rules.
- Campaign tags are read when a conversation starts. UTM parameters are taken from the page’s URL at the moment the visitor starts a chat, a call or the pre-chat form. If your app drops the query string on navigation, a visitor who browses before chatting arrives without them. Google Ads click IDs also fall back to gtag’s
_gcl_awand_gcl_gbcookies when your site runs gtag. See Chat.
More than one widget
A page can carry one widget. To use different widgets on different parts of your site, put a different snippet on each page. Each widget keeps its own conversation history in the visitor’s browser, so two widgets of one business never mix threads.
Rate limits
The widget’s public endpoints allow, by default, 30 requests per 15 minutes per visitor IP address, counted separately for each widget. Loading the widget’s settings, recording a page view, opening the launcher and starting a chat each count against the widget’s allowance. Chat messages count against the business’s. A single page view uses about three requests.
So a visitor who views more than about ten pages within 15 minutes, or several visitors sharing one public IP address such as an office network, can use up the allowance. The widget then doesn’t appear, or a message fails, until the window resets. If that’s a problem for your traffic, contact Zoie support.
Troubleshooting
Set window.__ZOIE_WIDGET_DEBUG__ = true before the snippet to get a log line for each start-up step. Messages are prefixed [ZoieWidget].
| Symptom | Likely cause | Fix |
|---|---|---|
No [ZoieWidget] build: line in the console | The script never ran: wrong src, blocked by script-src, or the tag manager tag didn’t fire. | Check the Network tab for widget-bundle.js. |
getByWidgetId: no agent for this widget_id with Widget not found | The key in data-widget-id is wrong, or the widget was deleted. | Copy the snippet again from the Publish dialog. |
The same message with widget_inactive | The widget has been deactivated. Its badge in the Widgets list reads Inactive. | Contact Zoie support, or create a new widget and use its snippet. |
Widget is paused on this website (an info line, not an error) | This website’s toggle is off in the Publish dialog. The server answers 403 with domain_disabled. | Switch the website back on in the Publish dialog. |
The same message with origin_not_allowed | This domain isn’t in Allowed Domains. Staging hosts need their own entry or a *. wildcard. | Add the domain. |
getByWidgetId request failed (network/CORS/CSP) | connect-src blocks https://api-us.zoie.ai, a proxy or extension blocked the request, or the rate limit was hit. | Fix the CSP. A 429 response in the Network tab means the rate limit. |
| The script runs without errors but no launcher appears | AI is off for the business or for the widget channel. | In Settings → AI Configuration, turn on Global AI Control and AI replies for Widget. See AI configuration. |
Webchat socket connect_error | The WebSocket to wss://api-us.zoie.ai is blocked. | Add it to connect-src, and allow WebSockets through any proxy. |
| Speak with Agent fails | Microphone blocked by Permissions-Policy, the page isn’t HTTPS, or connect-src blocks LiveKit. | See Voice calls and the microphone. |
| The launcher sits behind a sticky header, cookie banner or chat bubble | Another element also uses the top of the z-index range. | The widget uses z-index: 2147483000. Lower the other element, or move the widget to the other corner in Widget appearance. |
| Edits in the editor don’t show | The page was loaded before you saved. | Settings are fetched on every page load and never cached, so reload the page. |
Related
- Configuration — every attribute and option the script reads
- Chat — what the chat does and the data it keeps
- Installation snippets
- Widget setup and Capturing leads