Website chat widget
Put the chat agent on your website with one snippet.
On this page: Set up · The snippet · Allowed domains · Which key · Errors · Troubleshooting
Set up
- Allow your website. Open Security (under Embed & API)
and add your domain, for example
yourshop.com. An empty list allows nothing. - Style it. Open Widget and choose the colour, title, welcome message and corner.
- Copy the snippet from the same page and paste it into every page of your site, just before
</body>. Most site builders have a “custom code” or “footer scripts” box for this. - Test it on your live site. The chat button appears in the corner you chose.
The snippet
This is its shape. Copy yours from the Widget page: it carries your own key and settings.
<!-- Central AI Chatbot Widget -->
<script>
window.CentralAI = {
widgetKey: 'YOUR_WIDGET_KEY',
primaryColor: '#6366f1',
title: 'AI Assistant',
welcomeMessage: 'Hello! How can I help you today?',
position: 'bottom-right'
};
</script>
<script src="http://centralai.daffodil-bd.com/static/js/widget.js" async></script>
| Setting | What it does |
|---|---|
widgetKey | Your widget key (begins with ca_). Public by design. |
primaryColor | The button and header colour. |
title | The name in the chat header. |
welcomeMessage | The first message a visitor sees. |
position | bottom-right or bottom-left. |
The widget sends your key as X-Widget-Key, and gives each visitor’s browser its own
conversation token (X-Shopper-Token), so one visitor can never open another visitor’s
chat. You never create that token yourself. When the chat starts, the widget asks each visitor for a name, an email
address (required) and a phone number (optional); pressing Enter starts the chat. So every conversation belongs to a
contact, and the AI Sales Agent does not ask again for what the visitor gave. Conversations appear in Chat Logs.
Allowed domains
Because the widget key is visible in your page source, your allowed domains are what protect it: the widget answers only on pages whose origin is on your list. Manage the list on Security.
| Entry | Allows |
|---|---|
yourshop.com | That domain and every subdomain of it (www.yourshop.com, shop.yourshop.com), on any port. |
*.yourshop.com | Subdomains only; add yourshop.com as well for the bare domain. |
localhost:3000 | That host on that port only (for testing). localhost alone allows any port. |
null | Pages with no origin: local file:// pages and sandboxed frames. |
- Enter a domain without
https://or a path; the page removes them for you.httpandhttpscount as the same site. - Matching is by whole name:
yourshop.comdoes not let inyourshop.com.other-site.netormyyourshop.com. - The same list also protects the Chat API and the lead capture tracker.
Widget key or external API key?
Widget key public
Sent by the chat widget snippet. Begins with ca_. It is in your page source by design, and your allowed domains are what protect it. It is not accepted by any server-to-server API after the sunset date.
External API key secret
The secret key for every server-to-server API. Begins with cax_. Call these APIs from your own server only. Never put it in a snippet.
What the widget can answer
You do not call the widget’s routes yourself; these codes help you read your browser’s console.
| Code | HTTP | Meaning |
|---|---|---|
AUTH_REQUIRED | 401 | No widget key was sent. |
INVALID_AUTH | 401 | The widget key is not a live key of an active company. |
LEGACY_AUTH_RETIRED | 401 | An old snippet that sends your company name. Copy the snippet again. |
NO_DOMAINS_CONFIGURED | 403 | Your allowed-domains list is empty. |
ORIGIN_NOT_ALLOWED | 403 | The page is not on your allowed-domains list. |
SHOPPER_TOKEN_REQUIRED | 401 | This browser's conversation could not be verified. Reloading the page fixes it. |
RATE_LIMITED | 429 | Too many messages from one visitor. |
QUOTA_EXCEEDED | 403 | Your chat credits are used up. |
SALES_BUSY | 429 | Your Sales agent is answering more messages than your per-minute or per-hour limit allows. Retry after the Retry-After seconds; nothing was charged. |
NO_SUBSCRIPTION | 403 | Your company has no subscription. |
SUBSCRIPTION_INACTIVE | 403 | Your subscription is not active. |
METHOD_NOT_ALLOWED | 405 | Wrong method for this route. |
INVALID_JSON | 400 | The body is not a JSON object. |
EMAIL_REQUIRED | 400 | The visitor gave no email address. |
EMAIL_INVALID | 400 | The email address was refused. |
MESSAGE_REQUIRED | 400 | The message was empty. |
AGENT_ERROR | 503 | The agent could not produce an answer. The visitor is shown an apology; retry after Retry-After seconds. |
AGENT_FAILED | 503 | The agent returned a failure. The visitor is shown an apology; retry after Retry-After seconds. |
Troubleshooting
- The chat button does not appear.
- Check the snippet is on the page (view the page source) and that nothing blocks
widget.js. Open the browser console and look for an error code. NO_DOMAINS_CONFIGUREDorORIGIN_NOT_ALLOWED.- Add the exact domain the page is served from on Security. Remember
*.entries do not cover the bare domain. LEGACY_AUTH_RETIRED.- Your snippet is an old one that sends your company name. Copy the snippet again from the Widget page.
QUOTA_EXCEEDED.- Your chat credits are used up for this period. See Billing & Usage.
- I regenerated my widget key and the chat stopped.
- The old key stops working at once. Paste the new snippet on every page.
Signed in? Your own keys, endpoint addresses and the full error tables are
on the API reference inside your dashboard. These public pages never show
anyone’s key: examples use placeholders such as YOUR_EXTERNAL_API_KEY.