Widget Installation & Embedding Guide
Step-by-step guide to installing and embedding the Playbott AI customer support chat widget on any website using a lightweight HTML snippet.
Embedding the Playbott Chat Widget
Deploying the Playbott AI chat widget on your website takes less than two minutes. The widget operates as a sandboxed, asynchronous runtime that connects your visitors to automated AI resolution and human support escalation.
graph TD
A[Visitor Opens Website] --> B(Async widget.js Loader)
B --> C{Authenticated User?}
C -->|data-auth-info| D[Initialize Identified Identity]
C -->|Anonymous Visitor| E[Initialize Guest Session]
D --> F[Connect Real-time Gateway]
E --> F
F --> G[Render Floating Chat Launcher]The loader script (widget.js) is completely standalone. It requires zero third-party dependencies, jQuery, or frontend frameworks.
Prerequisites
Before adding the widget snippet to your website HTML:
- Active Playbott Account: Sign in to your Playbott Dashboard.
- Registered Website: Navigate to Organisation Settings → Websites and verify your website domain is registered.
- Public Key: Copy your unique Website Public Key (
data-key) from the website detail card.
Step 1: Add the Embed Code
Paste the following <script> tag into your website template right before the closing </body> tag on every page where you want the chat widget to appear:
<!-- Playbott AI Chat Widget -->
<script
src="https://playbott.com/widget.js"
data-key="YOUR_WEBSITE_PUBLIC_KEY"
async
></script>
Replace YOUR_WEBSITE_PUBLIC_KEY with the actual public key from your dashboard.
Always use the async attribute. This guarantees that script evaluation never delays DOM construction or primary content rendering.
Step 2: Configuration Attributes
You can customize runtime behavior by adding optional data-* attributes directly to the <script> tag:
| Attribute | Type | Default | Description |
|---|---|---|---|
data-key | string | Required | Your unique Website Public Key. |
data-dark-mode | boolean | false | Force dark mode ("true") or inherit the website's .dark class. |
data-auth-info | JSON string | null | Identify authenticated visitors with user attributes. |
data-api | URL | Default endpoint | Custom API endpoint for enterprise private cloud installations. |
data-socket | URL | Default endpoint | Custom WebSocket gateway URL for real-time messaging. |
Identifying Logged-in Users
If your users log in to your web application, pass their profile information using data-auth-info so agents know who they are talking to:
<script
src="https://playbott.com/widget.js"
data-key="YOUR_WEBSITE_PUBLIC_KEY"
data-auth-info='{"name": "Alex Mercer", "email": "alex@example.com", "id": "usr_94812"}'
async
></script>
Step 3: Content Security Policy (CSP)
If your website enforces a strict Content Security Policy, update your headers or <meta http-equiv="Content-Security-Policy"> tag to permit Playbott assets and WebSocket connections:
Content-Security-Policy:
script-src 'self' https://playbott.com;
connect-src 'self' https://playbott.com wss://playbott.com;
frame-src 'self' https://playbott.com;
If your site uses strict iframe sandboxing directives, ensure allow-scripts, allow-same-origin, and allow-forms are enabled on host containers.
Single Page Applications (SPA) Support
The Playbott loader automatically intercepts client-side routing in frameworks such as Next.js, React Router, Vue Router, and Angular.
- Tracks
window.history.pushStateandwindow.history.replaceState. - Listens to
popstateandhashchangebrowser events. - Evaluates dynamic URL visibility rules seamlessly without requiring manual teardown or re-initialization.
Troubleshooting
Widget launcher does not appear
- Verify
data-keyis exact and has no trailing whitespace. - Check browser DevTools console for CSP or network block errors.
- Ensure the domain in the browser address bar matches the domain registered in Organisation Settings → Websites.
Launcher appears on wrong pages
- Review your path-based visibility rules under Website Settings → Widget Settings.
Next Steps
- Explore Widget Customization & Styling to tailor colors, position, greeting messages, and themes.
- Connect Slack Integration to respond to customer inquiries directly from your team's Slack channels.
Frequently Asked Questions
Does the Playbott chat widget impact page load speed?
No. The loader script is under 16 kB gzip and executes asynchronously without blocking DOM parsing, rendering, or Core Web Vitals (LCP/FID/CLS).
Can I install the widget on Single Page Applications (React, Vue, Next.js)?
Yes. The loader automatically tracks route changes via popstate, hashchange, and history pushState/replaceState observers to update contextual visibility.
What domains need to be permitted in our Content Security Policy (CSP)?
Add https://playbott.com to script-src, frame-src, and connect-src (along with wss://playbott.com for real-time WebSocket communication).
Ready to deploy Playbott on your website?
Get started in minutes with our embedded AI chat widget and omnichannel ticketing.