Developer Documentation
Everything you need to seamlessly integrate SiteBot into your application. Browse our guides, API references, and configuration options.
On this page
Quick Start
After creating a chatbot on SiteBot, you receive a unique namespace. Add one script tag to your HTML and the widget loads automatically.
Two modes
- Dynamic — only
data-namespacein the tag. Config is fetched from the server. Dashboard changes take effect instantly. Best for SPAs and frameworks (React, Next.js, Vite, Vue). - Static — add any
data-*attribute to the tag. Those values are locked and never overwritten by the server. Best for static HTML sites, WordPress, and hardcoded pages where you control the embed snippet directly.
No environment variables required. The namespace is the only value you need — pass it directly in the script tag or as a prop in your framework component.
<script
src="https://sitebot.online/embed.js"
data-namespace="YOUR_NAMESPACE"
></script>Dynamic Mode
In dynamic mode, the only value you set in the embed snippet is data-namespace. Every other config value (title, colors, icon, shape, welcome message) is fetched from the server at load time. Changes you make in the SiteBot dashboard are reflected instantly — no redeploy needed.
How it works
- embed.js reads the script tag and builds an "explicit" map — any attribute present on the tag is marked as explicitly set.
- embed.js fetches config from the server: GET /api/chatbot/config?namespace=YOUR_NAMESPACE.
- For every config key: if the key is NOT in the explicit map, the server value is used. If it IS explicit, the server value is ignored.
- Since only data-namespace is on the tag, all other keys come from the server.
Step by step
- Copy your namespace from the SiteBot dashboard (Create Chatbot page).
- Add the script tag to your HTML, setting only data-namespace.
- Deploy. The widget loads with your server-configured title, colors, icon, shape, and welcome message.
- To change any config: edit it in the dashboard. The next page load picks it up — no code changes.
<script
src="https://sitebot.online/embed.js"
data-namespace="YOUR_NAMESPACE"
></script>Key rule: If you add data-title="Support" to the tag, the dashboard title is ignored for that attribute. Only data-namespace should be present for full dynamic behavior.
Static Mode
In static mode, you add data-* attributes directly to the script tag. These values are locked — the server fetch still happens, but any key that is already present on the tag is never overwritten.
Step by step
- Copy your namespace from the SiteBot dashboard.
- Add the script tag with data-namespace plus any other attributes you want to lock.
- Each attribute you add becomes "explicit" — it will always use your value, regardless of dashboard changes.
- Attributes you omit still come from the server (dynamic fallback).
<script
src="https://sitebot.online/embed.js"
data-namespace="YOUR_NAMESPACE"
data-title="Support Assistant"
data-welcome="Hi! How can I help you today?"
data-position="right"
data-shape="circle"
data-primary-color="#fa5d19"
data-header-bg="#1e293b"
data-bot-bg="#f3f4f6"
data-user-bg="#fa5d19"
></script>Mixed mode
You can mix both approaches. Set only the attributes you want to lock; the rest come from the server. For example, lock the title and primary color but let the dashboard control everything else:
<script
src="https://sitebot.online/embed.js"
data-namespace="YOUR_NAMESPACE"
data-title="Always This Title"
data-primary-color="#fa5d19"
></script>React Integration
In React, use a useEffect hook to create the script element dynamically. This avoids next/script quirks with data-* attributes.
Dynamic mode
Only set dataset.namespace. All other config comes from the server.
'use client';
import { useEffect } from "react";
export function ChatWidget() {
useEffect(() => {
const s = document.createElement("script");
s.src = "https://sitebot.online/embed.js";
s.dataset.namespace = "YOUR_NAMESPACE";
document.body.appendChild(s);
}, []);
return null;
}Static mode
Set any dataset.* property to lock that value. Use camelCase: data-header-bg becomes dataset.headerBg.
'use client';
import { useEffect } from "react";
export function ChatWidget() {
useEffect(() => {
const s = document.createElement("script");
s.src = "https://sitebot.online/embed.js";
s.dataset.namespace = "YOUR_NAMESPACE";
s.dataset.title = "Support";
s.dataset.position = "right";
s.dataset.shape = "circle";
s.dataset.primaryColor = "#fa5d19";
s.dataset.headerBg = "#1e293b";
document.body.appendChild(s);
}, []);
return null;
}Use in your app: <ChatWidget /> in any page or layout.
Vite Integration
In a Vite project (Vue, React, or vanilla JS), you have two options: add the script tag directly to index.html, or load it dynamically from a component.
Option 1: index.html (simplest)
Vite injects index.html as the entry point. Add the script tag there — same as the plain HTML approach above.
<!-- dynamic mode: only namespace -->
<script
src="https://sitebot.online/embed.js"
data-namespace="YOUR_NAMESPACE"
></script>Option 2: Dynamic from a component
If you need the widget to load conditionally or with runtime values, create the script element in a component:
// React
import { useEffect } from "react";
export function ChatWidget({ namespace }: { namespace: string }) {
useEffect(() => {
const s = document.createElement("script");
s.src = "https://sitebot.online/embed.js";
s.dataset.namespace = namespace;
document.body.appendChild(s);
}, [namespace]);
return null;
}
// Vue — same idea in onMounted():
// const s = document.createElement("script");
// s.src = "https://sitebot.online/embed.js";
// s.dataset.namespace = props.namespace;
// document.body.appendChild(s);For static mode, add s.dataset.title = "..." etc. before appending.
Next.js Integration
In Next.js, use a client component with useEffect. Do not use next/script — it does not reliably set data-* attributes on the DOM element.
Step by step
- Create a client component: add "use client" at the top.
- In useEffect, create a script element with document.createElement("script").
- Set s.src and s.dataset.namespace (dynamic) or additional dataset.* (static).
- Append to document.body.
- Render the component in your root layout or any page.
Dynamic mode
"use client";
import { useEffect } from "react";
export function ChatWidget() {
useEffect(() => {
const s = document.createElement("script");
s.src = "https://sitebot.online/embed.js";
s.dataset.namespace = "YOUR_NAMESPACE";
document.body.appendChild(s);
}, []);
return null;
}Add to your root layout:
import { ChatWidget } from "@/components/ChatWidget";
export default function RootLayout({ children }) {
return (
<html>
<body>
{children}
<ChatWidget />
</body>
</html>
);
}Static mode
'use client';
import { useEffect } from "react";
export function ChatWidget() {
useEffect(() => {
const s = document.createElement("script");
s.src = "https://sitebot.online/embed.js";
s.dataset.namespace = "YOUR_NAMESPACE";
s.dataset.title = "Support";
s.dataset.position = "right";
s.dataset.shape = "circle";
s.dataset.primaryColor = "#fa5d19";
s.dataset.headerBg = "#1e293b";
document.body.appendChild(s);
}, []);
return null;
}Why not next/script? The Next.js Script component does not reliably pass data-* attributes to the DOM. document.createElement + dataset.* is the only reliable approach.
Widget Options
All options are set as data- attributes on the script tag. In React/Vue/Next.js, use dataset.* (camelCase). The attribute name maps by removing data- and converting kebab-case to camelCase.
General
| Attribute | Default | Description |
|---|---|---|
| data-namespace | — | Your chatbot namespace (required)(required) |
| data-title | Chat Assistant | Header title |
| data-welcome | Hi there! Ask me anything. | Welcome message |
| data-position | right | left or right |
| data-shape | circle | circle or square |
| data-placeholder | Type your message... | Input placeholder text |
| data-icon | — | Custom icon image URL for the bubble |
| data-theme | auto | auto, light, or dark |
| data-api-url | (auto-derived) | API base URL (auto-derived from script src) |
| data-width | 380 | Panel width in px |
| data-height | 500 | Panel height in px |
| data-bubble-size | 60 | Bubble diameter in px |
| data-offset-bottom | 24 | Bubble distance from bottom in px |
| data-offset-side | 24 | Bubble distance from side in px |
Layout & Typography
| Attribute | Default | Description |
|---|---|---|
| data-border-radius | auto | Panel border radius |
| data-panel-border-color | — | Panel border color |
| data-msg-gap | — | Gap between messages |
| data-msg-font-size | — | Message font size |
| data-msg-max-width | — | Max width of message bubbles |
| data-font-family | — | Custom font family |
| data-custom-css | — | Custom CSS injected into the widget |
Header
| Attribute | Description |
|---|---|
| data-header-bg | Header background |
| data-header-title-color | Header title text color |
| data-header-status-color | Online status text color |
| data-header-avatar-bg | Avatar circle background |
| data-online-text | Online status text |
| data-online-dot-color | Online indicator dot color |
| data-close-btn-color | Close button color |
Messages
| Attribute | Description |
|---|---|
| data-bot-bg | Bot message background |
| data-bot-color | Bot message text |
| data-user-bg | User message background |
| data-user-color | User message text |
| data-bg | Chat area background |
| data-text | General text color |
| data-text-secondary | Secondary text color |
| data-typing-bg | Typing indicator background |
| data-typing-dot-color | Typing indicator dot color |
Input
| Attribute | Description |
|---|---|
| data-input-bg | Input field background |
| data-input-text-color | Input text color |
| data-input-border-color | Input border color |
| data-input-placeholder-color | Placeholder text color |
| data-send-bg | Send button background |
Bubble & Welcome Screen
| Attribute | Description |
|---|---|
| data-primary-color | Primary brand color (buttons, accents, bubble default) |
| data-bubble-color | Bubble icon color |
| data-welcome-icon-bg | Welcome screen icon background |
| data-welcome-title-color | Welcome screen title color |
| data-welcome-text-color | Welcome screen body text color |
Theme Colors
All colors accept any valid CSS color value. Use the attribute names from the tables above. In dataset.* (React/Vue/Next.js), use camelCase — e.g. data-primary-color becomes dataset.primaryColor.
JavaScript SDK
For runtime control, use the globally injected window.SiteBot object. This is useful for single-page applications that need to update config without reloading.
window.SiteBot.configure({
title: "Sales Assistant",
welcome: "Interested in our enterprise plans?",
primaryColor: "#fa5d19",
shape: "circle",
position: "right",
});window.SiteBotConfig can also be set before the embed script loads to inject config at page load time.
<script>
window.SiteBotConfig = {
title: "Locked Title",
primaryColor: "#fa5d19",
};
</script>
<script
src="https://sitebot.online/embed.js"
data-namespace="YOUR_NAMESPACE"
></script>