Skip to content
This site is under construction. Content, screenshots, and workflows may change at any time.

Embed the Widget

Once your bot is trained, embed it anywhere — WordPress, Next.js, plain HTML, Webflow, Shopify. Two script tags, no build step, mounts in a shadow DOM so your CSS stays clean.

1. Get your embed code

Open your bot’s Dashboard. Scroll to Chat Widget Embed at the bottom. You’ll see two pre-filled <script> tags with your bot ID baked in. Click Copy Embed.

Bot Dashboard with Chat Widget Embed section showing two script tags and Copy Embed button

The snippet looks like this (your bot ID will differ):

HTML
<script
type="module"
src="https://cdn.jsdelivr.net/gh/fluent-docai/chat-widget@latest/chat-widget.js"
></script>
<script type="module">
FluentBotChatWidget.injectWidget("YOUR_BOT_ID");
</script>

Use the copied snippet as-is. It should load the widget script from the FluentBot CDN, not from a development host.

2. Install it

Plain HTML

Paste the snippet right before </body>:

HTML
<body>
<!-- ...your page... -->
<script
type="module"
src="https://cdn.jsdelivr.net/gh/fluent-docai/chat-widget@latest/chat-widget.js"
></script>
<script type="module">
FluentBotChatWidget.injectWidget("YOUR_BOT_ID");
</script>
</body>

WordPress

  • Block editor (any modern theme): add a Custom HTML block at the bottom of every page (or in a footer template part), paste the two <script> tags, save.
  • Classic theme: open footer.php, paste before </body>.
  • Plugin route: install any “Insert Headers and Footers” plugin, paste into the footer field — applies site-wide.

Framework examples

Pick your framework and add the snippet in the file shown at the top of the example.

app/layout.tsx
import Script from "next/script";
export default function RootLayout({
children,
}: {
children: React.ReactNode;
}) {
return (
<html>
<body>
{children}
<Script
type="module"
src="https://cdn.jsdelivr.net/gh/fluent-docai/chat-widget@latest/chat-widget.js"
strategy="afterInteractive"
/>
<Script id="fluentbot-init" type="module" strategy="afterInteractive">
{`FluentBotChatWidget.injectWidget("YOUR_BOT_ID");`}
</Script>
</body>
</html>
);
}

The __fbWidget guard in the React and Vue examples prevents double-mounting on development re-renders. In Astro, is:inline prevents the inline init script from being bundled.

Shopify

Settings → Edit code → theme.liquid → paste both script tags right before </body>.

Webflow

Project Settings → Custom Code → Footer Code → paste both script tags.

Wix

Open the Embed Code widget (Add Elements → Embed → Custom Code), paste both <script> tags, set placement to Body — end.

Squarespace

Settings → Advanced → Code Injection → Footer → paste both script tags. Available on Business plans and above.

SPA caveat

For all SPA frameworks above (React, Vue, Nuxt, SvelteKit, Astro, Remix, Gatsby, Angular): mount the widget once at app startup, not on every route change. The widget instance persists across client-side navigations. Re-mounting causes duplicate widgets.

If your site passes a signed visitor identity, wait until the logged-in visitor is known before calling FluentBotChatWidget.injectWidget(...) — see Widget SDK.

3. Verify

  1. Open your site in an incognito window.
  2. A floating bubble appears in the bottom-right corner.
Sample test page with the chat-widget bubble visible in the bottom-right
  1. Click the bubble. The widget expands with a header (your bot name), a greeting, and a compose box.
Widget expanded showing the bot greeting and compose box
  1. Send a test message. The bot should answer using your sources.

Troubleshooting

  • Widget doesn’t appear — check the browser console for CSP or CORS errors. Whitelist cdn.jsdelivr.net if your CSP blocks third-party scripts.
  • Widget appears but won’t chat — verify the bot ID in injectWidget(...) matches the one on your bot Dashboard. Mismatched ID = silent fail.
  • FluentBotChatWidget is not defined — first script tag didn’t load before the second one ran. Make sure both <script type="module"> tags are present and in order. With next/script, both must use strategy="afterInteractive".
  • Style clash — the widget renders inside a shadow DOM, so host-page CSS shouldn’t leak in. If it does, file a ticket.
  • CSP blocks unpkg or jsdelivr — add script-src 'self' https://cdn.jsdelivr.net (and connect-src for API calls back to your FluentBot host) to your Content-Security-Policy.

What’s next