Chat Widget embed

HTML & static sites

Add the Assistrio chat widget to plain HTML or a static site — Jekyll, Hugo, Eleventy, PHP, Django, or Rails templates — once before the body tag.

For plain HTML, static site generators (Jekyll, Hugo, Eleventy, Hexo), and server-rendered templates (PHP, Django, Rails, Laravel, Express views), paste the install code once in the template every page shares.

Get your install code

  1. 1

    Open Deploy › Chat Widget

    In Assistrio, open your agent, click Deploy in the top bar, and pick Chat Widget.

  2. 2

    Allow your domains

    Under Allowed websites, add the domain your app runs on in production (and a staging domain, if you test there). See Allowed websites.

  3. 3

    Copy Snippet

    Under Install code, click Copy Snippet. Replace the placeholder code below with yours — it has your real agentId.

Your install code looks like this
<link rel="stylesheet" href="https://widget.assistrio.com/assistrio-chat.css" />
<script>
  window.AssistrioChatConfig = {
    agentId: "YOUR_AGENT_ID",
    apiBaseUrl: "https://chat.assistrio.com",
    position: "right"
  };
</script>
<script src="https://widget.assistrio.com/assistrio-chat.js" async></script>

Add it to your app

  1. 1

    Find the shared template

    The layout or footer every page includes: _layouts/default.html (Jekyll), layouts/_default/baseof.html (Hugo), _includes/layout.njk (Eleventy), base.html (Django), application.html.erb (Rails), app.blade.php (Laravel).

  2. 2

    Paste before </body>

    Paste the whole install code just before </body>. (The <link> may also go in <head>.)

  3. 3

    No shared template?

    Paste it into every .html page, just before </body>.

index.htmlHTMLOnce, before </body>
1 <body>
2 <!-- your page -->
3 <link rel="stylesheet" href="…/assistrio-chat.css" />
4 <script>window.AssistrioChatConfig = { agentId: "…" };</script>
5 <script src="…/assistrio-chat.js" async></script>
6 </body>
7</html>
Plain HTML: the code once, just before </body>, in the template every page shares.

Local development

The chat only loads on your allowed websites, so it stays hidden on localhost — that's expected. Test on a preview or staging domain you've added (each agent can have up to 3), or test the agent itself in the Playground.

Check it works

  • Deploy, open your site on an allowed domain, and look for the launcher at the bottom right. Send “Hi”.
  • In the browser console, window.AssistrioChat?.isMounted() returns true.
  • Nothing? Look for an [Assistrio Chat] warning in the console — it names the problem (missing agentId, website not allowed, and so on). See Troubleshooting.

Pass a signed-in user

Server-rendered page? Render userId and userHash straight into the config for signed-in users (leave both out for guests). The hash is HMAC-SHA256 of the user ID with your agent's secret key, made on your server — never put the key in browser code. See Identity verification.

PHP template
<script>
  window.AssistrioChatConfig = {
    agentId: "YOUR_AGENT_ID",
    apiBaseUrl: "https://chat.assistrio.com",
    position: "right",
    // Rendered by your server for signed-in users only:
    userId: "<?= htmlspecialchars($user->id) ?>",
    userHash: "<?= hash_hmac('sha256', (string) $user->id, getenv('ASSISTRIO_SECRET_KEY')) ?>"
  };
</script>

Install with AI

Using Claude Code, Cursor, GitHub Copilot, Windsurf, or another coding assistant? Pick it, copy the prompt, paste it into the tool, then paste your install code where it says. It's written for HTML & static sites. Tip: Deploy › Chat Widget › Install with AI in Assistrio gives the same picker with your code and websites already filled in.

AI tool you use

Add the "Assistrio" AI Chat Widget to my website.

What to do:
- Paste the code just before </body> in the shared footer or template, so it's on every page. If there is no shared footer, add it to each page.
- Add it only once. Don't add it twice or load it again on each page change.
- Paste the code exactly as it is. Don't change the agentId or the URLs.

How to check it works:
- Open the website: a Chat Widget shows at the bottom right.
- Send it a message like "Hi": the agent answers.
- If it doesn't show, check the code is on the page and look for an [Assistrio Chat] message in the browser console.

The code:
[Paste your install code from Assistrio › Deploy › Chat Widget › Copy Snippet here]

Replace the last line with your install code from Deploy › Chat Widget › Copy Snippet. In Assistrio, Install with AI fills it in for you.

Signing in users too? Add this line under What to do:

Extra line — signed-in users
- Identity verification is on: on the server, for each signed-in user, set userId to their id and userHash to HMAC-SHA256(userId) in hex, made with the secret key read from an environment variable named ASSISTRIO_SECRET_KEY. For visitors who aren't signed in, leave both out. Never put the secret key in browser code.

Content Security Policy

If your site sends a Content-Security-Policy header, add these sources to it. They're everything the Chat Widget and Center Stage load. The inline config <script> also needs to be allowed (with a nonce or hash), or move it into a file you serve yourself.

CSP sources to add
script-src  https://widget.assistrio.com;
style-src   https://widget.assistrio.com 'unsafe-inline';
connect-src https://widget.assistrio.com https://chat.assistrio.com;
img-src     https: data: blob:;
media-src   https://assistrio-public-assets.s3.us-east-1.amazonaws.com blob:;
frame-src   https://calendly.com;
DirectiveWhy the widget needs it
script-srcThe widget script, assistrio-chat.js.
style-srcThe stylesheet, plus the <style> tags the widget puts inside its own shadow root (hence 'unsafe-inline').
connect-srcchat.assistrio.com for chat, file uploads, voice, and analytics; widget.assistrio.com for a small location check when the chat starts.
img-srcYour agent's avatar and uploaded files, product photos from your store's own image host (like cdn.shopify.com), and previews of files a visitor attaches (blob:).
media-srcVoice messages: recorded ones play from blob:, sent ones from Assistrio's file storage.
frame-srcOnly if you use a Calendly booking action: the booking page opens inside the chat. Cal.com times show in the chat itself, with no frame.

Note

Using voice messages or dictation? Your site must also allow the microphone (no Permissions-Policy: microphone=() header). For the iframe, keep allow="clipboard-write; microphone" on the tag.

Next steps

Was this page helpful?

Need help? Contact support — we reply within one to two business days.