Embed the Chat Widget
Add the AgentStack chat bubble to any website — plain HTML or a framework — and avoid the two mistakes that make it silently fail to appear.
The chat widget is two <script> tags. The hard part isn't the snippet — it's
putting it where it actually renders, and configuring the allowed domains
correctly. Get those two things right and the bubble shows up everywhere.
The snippet
Copy this from your agent's Deploy → Chat Widget page (it already has your agent ID baked in):
Replace YOUR_AGENT_ID with the ID shown on the Deploy page.
Let your coding agent install it
If you use Claude Code, Cursor, or another AI coding agent, paste the prompt below. It tells the agent how to detect your framework and place the snippet in the one file that wraps every page — the most common reason the widget never shows is that it gets added to a file that doesn't actually render on the public site.
Swap YOUR_AGENT_ID in the prompt for your real agent ID before sending it.
Domain protection: do not use *. wildcards
On the Deploy page you can restrict which domains may embed your agent. This is
where fresh installs most often break. The matcher supports exact hostnames
and automatic subdomain coverage — it does not support *. glob
wildcards.
| You want to allow | Enter this | Don't enter |
|---|---|---|
example.com and all its subdomains (www., app., …) | example.com | *.example.com |
Only app.example.com | app.example.com | — |
| Local development | localhost | — |
Rules:
- A bare domain already covers its subdomains.
example.commatchesexample.com,www.example.com,app.example.com, and so on. You do not need a separate wildcard line. *.example.commatches nothing. The literal*.is stored as-is and never matches a real hostname, so the chat panel is blocked on every domain.- Enter the host only — no
https://, nowww.prefix needed, no trailing path.https://example.com/will not match;example.comwill. - Leave the field empty to allow all domains. Only fill it in when you want to restrict embedding.
Verify the install
- Open your public site (the real domain, not a preview URL — domain protection blocks hosts that aren't on the allow-list).
- Open DevTools → Console and run
window.agentstack. If it'sundefined, the snippet isn't on the page → it's in the wrong file (see the framework list above). - DevTools → Network:
embed.jsshould return 200. - The bubble should appear (bottom-right by default). Click it — the chat panel
should load. A bubble that opens to an empty/error panel almost always means a
domain-protection mismatch (the
*.wildcard mistake above).
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
No bubble at all; window.agentstack is undefined | Snippet in a file that doesn't render on the public site (e.g. Next.js App Router layout while the site uses the Pages Router) | Move it to the file that wraps every page |
No bubble; window.agentstack is defined | Agent isn't public, or geo-restricted | Toggle the agent public on the Deploy page; check geo settings |
| Bubble appears but panel is empty / "not allowed on this domain" | Domain protection mismatch — usually a *. wildcard or a https://-prefixed entry | Use the bare hostname; remove *. and scheme |
| Works locally, not in production | localhost allowed but production domain isn't on the list | Add the production hostname (bare) |