Prerequisites
From the workspace operator (or Settings → Integrations → Channels → Website widget if that’s you):- The install snippet (or just the widget slug and API base URL).
- Confirmation that your site’s origin is in the widget’s allowed origins list — the exact scheme + host, e.g.
https://www.example.com.wwwand apex are different origins; add both if both serve the site.
https://api.switchbord.ai. Self-hosted instances substitute their own API domain everywhere it appears below.
The snippet
Paste this before the closing</body> tag on every page that should show the widget:
Framework recipes
Plain HTML / any server-rendered site
Plain HTML / any server-rendered site
Paste the snippet before
</body> in your base layout/template so it appears on every page. Done.Next.js (App Router)
Next.js (App Router)
Use Do not render the script inside pages that remount on navigation — the loader is idempotent (it won’t create a second iframe), but loading it once in the layout is cleaner.
next/script in the root layout so the widget loads once per navigation session, client-side only:React (Vite / CRA SPA)
React (Vite / CRA SPA)
Load once in a top-level effect:
Google Tag Manager
Google Tag Manager
Create a Custom HTML tag containing the snippet, trigger it on All Pages (or a page-path trigger if you only want it on some pages), and publish. Remember GTM fires from your site’s origin, so the origin allowlist requirement is unchanged.
WordPress
WordPress
Either paste the snippet into your theme’s
footer.php before </body>, or use any “insert headers and footers” plugin and place it in the footer section. Site-builder platforms (Webflow, Squarespace, Shopify) all have an equivalent “custom code before </body>” setting.Content-Security-Policy
If your site ships a CSP, allow the Switchbord API origin in these directives:JavaScript SDK
The loader exposeswindow.SwitchbordWidget:
Events for
on(event, fn):
Signed identity (Secure Mode)
If your site has logged-in users, mint a short-lived HS256 JWT on your server and pass it tologin() so Switchbord verifiably knows who the visitor is. Verified visitors resume their conversation across devices, and operators see verified contact details instead of anonymous sessions.
Setup:
- In Switchbord, generate the Widget identity signing secret under Settings → Integrations → Provider secrets (
widget-identity-secret). It is stored in the workspace Vault; the browser never sees it. - Set the widget’s identity mode in the widget settings (and optionally Require identity to block messaging until login).
- Mint tokens server-side with these claims:
Verify the install
- Open your site — the launcher bubble appears bottom-right (or bottom-left per theme) within a second or two.
curl https://api.switchbord.ai/api/v1/widgets/YOUR_WIDGET_SLUG/configreturns200with the widget config JSON.- Send a test message from the widget — it appears in the Switchbord inbox in real time.
- Reply from the inbox — the visitor sees it (with the operator’s name) within a few seconds; if the panel is closed, an unread badge appears on the launcher.
- If AI mode is draft or auto-send, the test message produces a GBCA draft (or autonomous reply) after a short debounce.
Troubleshooting
Install prompt for AI coding agents
Give this to Cursor, Claude Code, Copilot, or any coding agent working on your website. Replace the two placeholders, paste, and let it run.Localhost testing: add
http://localhost:3000 (or your dev port) to the widget’s allowed origins while developing, and remove it before go-live. An empty allowlist allows all origins — fine for a first smoke test, not for production.