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 is not the snippet. The
hard part is where you place it, and how you configure the allowed domains. If
you get both steps right, the bubble shows up everywhere.
The snippet
Copy the snippet from your agent's Deploy → Chat Widget page. This page already includes your agent ID.
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. The prompt tells the agent how to detect your framework and place the snippet in the one file that wraps every page. Most installs fail because the snippet ends up in a file that does not render on the public site.
Swap YOUR_AGENT_ID in the prompt for your real agent ID before you send it.
Domain protection: do not use *. wildcards
On the Deploy page, you can restrict which domains can embed your agent. This
is where fresh installs most often fail. The matcher supports exact
hostnames and automatic subdomain coverage. The matcher does not
support *. glob wildcards.
| You want to allow | Enter this | Do not 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 system stores the literal*.as plain text. It never matches a real hostname. As a result, no domain can open the chat panel.- Enter the host only. Do not add
https://. Do not add awww.prefix or a trailing path.https://example.com/does not match.example.commatches. - Leave the field empty to allow all domains. If you want to restrict embedding, enter a domain in the field.
Verify the install
- Open your public site. Use the real domain, not a preview URL. Domain protection blocks hosts that are not on the allow list.
- Open DevTools → Console. Run
window.agentstack. If the result isundefined, the snippet is not on the page. The snippet is in the wrong file. See the framework list above. - Open DevTools → Network.
embed.jsmust return 200. - The bubble appears in the bottom-right corner by default. Click it. The chat
panel loads. When a bubble opens to an empty panel or an error panel, this
usually means a domain-protection mismatch. See the
*.wildcard mistake above.
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
No bubble appears, and window.agentstack is undefined | The snippet is in a file that does not render on the public site (for example, a Next.js App Router layout when the site uses the Pages Router) | Move the snippet to the file that wraps every page |
No bubble appears, but window.agentstack is defined | The agent is not public, or the agent is geo-restricted | Make the agent public on the Deploy page. Check the geo settings. |
| The bubble appears, but the panel is empty or shows "not allowed on this domain" | Domain-protection mismatch, usually a *. wildcard or an entry with a https:// prefix | Use the bare hostname. Remove the *. and the scheme. |
| The widget works locally, but not in production | localhost is on the allow list, but the production domain is not | Add the bare production hostname |