Web Widget
Add a chat widget to your website so visitors can ask questions and get instant answers from your knowledge base.
What You Get
- One line of code — paste a script tag and you’re done
- Dedicated knowledge base for your website
- Real-time streaming — answers appear word by word
- Customizable colors to match your brand
- Mobile friendly — full-screen on small devices
- No impact on your site — runs in an isolated Shadow DOM
- Response tracking — all widget conversations appear in your dashboard
Prerequisites
Before adding the widget to your website, make sure you have:A BestChatBot account with an active workspace
Content in your knowledge base (documents or URLs)
Access to edit the HTML of the website where you want the widget
Create Your Widget
Choose Platform
From your workspace, you’ll see the Choose Platform dialog. Select Web Widget to embed chat on your website.

Configure Your Widget
Fill in the setup form:
- Name — a label for your widget (e.g., “My Website Widget”)
- Allowed Origins — the domains where the widget can run, one per line. Supports wildcards (
*.example.com). Leave empty to allow all. - Primary Color — your brand color in hex (e.g.,
#F97316)

Get Your Embed Code
Click the embed code button (<>) on your widget card, or go to Widget Settings → Installation tab. You’ll see a ready-to-paste snippet:

Install on Your Website
Paste the snippet into your website’s HTML, just before the closing</body> tag:
Platform-Specific Instructions
WordPress
WordPress
- Go to Appearance → Theme File Editor (or use a plugin like “Insert Headers and Footers”)
- Open
footer.php - Paste the snippet just before
</body> - Save changes
Shopify
Shopify
- Go to Online Store → Themes → Edit Code
- Open
theme.liquid - Paste the snippet just before
</body> - Save
Wix
Wix
- Go to Settings → Custom Code
- Click Add Custom Code
- Paste the snippet
- Set placement to Body - End
- Apply to All Pages
Squarespace
Squarespace
- Go to Settings → Advanced → Code Injection
- Paste the snippet in the Footer field
- Save
Next.js / React
Next.js / React
Add the script tag to your root layout or use the
next/script component:Static HTML / Other
Static HTML / Other
Paste the snippet before
</body> in your HTML file. Works with any website that supports custom HTML.How It Works
Once installed, the widget works like this:- Page loads → the script loads from BestChatBot’s servers
- Widget appears → a chat bubble shows in the bottom-right corner
- Visitor clicks → the chat window opens
- Visitor asks a question → the widget sends it to your knowledge base
- Answer streams in → the response appears word by word in real time
- Sources shown → relevant sources from your knowledge base are listed (expandable)
Conversation Memory
The widget remembers the conversation within the same browser session. If a visitor navigates to another page, their chat history is preserved. Clicking the + button in the header starts a fresh conversation.Widget Settings
Click the settings button (⚙) on your widget card to open the configuration panel. It has three tabs:
Configuration Tab
Change your brand color and allowed domains after creation. Primary Color — Choose your brand color using the color picker or enter a hex value (e.g.,#F97316). The widget automatically adjusts:
- Chat bubble accent
- User message border
- Send button color
- Text contrast (white or black) based on your color
| Format | Example | What It Matches |
|---|---|---|
| Exact URL | https://example.com | Only that exact domain |
| Wildcard | https://*.mysite.com | Any subdomain of mysite.com |
Supports wildcards like
*.example.com to cover all subdomains. You cannot use * alone.Installation Tab
View and copy your embed code snippet. Same as clicking the<> button on the widget card.
Danger Zone Tab

- Immediately invalidates the current API key
- Generates a new one
- Requires you to update the snippet on your website
”Powered by BestChatBot” Badge
The footer badge is shown by default on the Free and Starter plans. Upgrade to Pro or Business to hide it.| Plan | Badge |
|---|---|
| Free | Shown |
| Starter | Shown |
| Pro | Hidden |
| Business | Hidden |
Monitoring Widget Conversations
All conversations from your web widget appear in the Bot Responses page of your dashboard. Use the Web filter to see only widget conversations.

Mobile Experience
On screens smaller than 640px, the chat window automatically expands to full screen for a better mobile experience. The chat bubble adjusts its position to fit smaller screens.Advanced: Programmatic API
For developers who want more control, the widget exposes a JavaScript API onwindow.BestChatBot after it loads.
Available Methods
| Method | Description |
|---|---|
BestChatBot.open() | Open the chat window |
BestChatBot.close() | Close the chat window |
BestChatBot.toggle() | Toggle open/close |
BestChatBot.destroy() | Remove the widget from the page entirely |
BestChatBot.sendMessage(text) | Send a message programmatically (opens the window) |
BestChatBot.onReady(callback) | Run a function when the widget is ready |
BestChatBot.onMessage(callback) | Run a function when a new message arrives |
Examples
Open the widget when a button is clicked:The API is only available after the widget script has loaded. If you need to call it immediately, use
onReady() to wait for initialization.Compatibility
The widget works on all modern browsers:| Browser | Supported |
|---|---|
| Chrome 80+ | ✅ |
| Firefox 80+ | ✅ |
| Safari 14+ | ✅ |
| Edge 80+ | ✅ |
| Mobile Chrome | ✅ |
| Mobile Safari | ✅ |
| Internet Explorer | ❌ |
Troubleshooting
Widget doesn't appear
Widget doesn't appear
- Check that the
data-api-keyis correct - Verify your domain is in the Allowed Origins list (Widget Settings → Configuration)
- Open browser DevTools (Console tab) and look for
[BestChatBot]warnings - Make sure the script tag has the
deferattribute - Check that the widget is set to Active in the Widget Manager
Widget shows but doesn't respond
Widget shows but doesn't respond
- Check that your knowledge base has content and has been rebuilt
- Look for errors in the browser Console
- Verify your subscription is active
Styling conflicts
Styling conflicts
The widget runs inside a closed Shadow DOM, so conflicts are extremely rare. If you see issues:
- Check that you don’t have a global
* { all: unset }rule - Make sure no script is removing the
#bestchatbot-widget-hostelement
Widget appears on wrong pages
Widget appears on wrong pages
The script tag loads on every page where it’s included. To limit it:
- Add the snippet only to specific page templates
- Or use conditional loading with JavaScript:
Next Steps
Upload Documents
Add content for the widget to answer from.
Add URLs
Scrape your website content into the knowledge base.
Pricing Plans
Check plan features including widget limits.
Discord Integration
Set up a Discord bot in a separate workspace.


