Docs
Documentation

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

  1. Allow your website. Open Security (under Embed & API) and add your domain, for example yourshop.com. An empty list allows nothing.
  2. Style it. Open Widget and choose the colour, title, welcome message and corner.
  3. 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.
  4. 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>
SettingWhat it does
widgetKeyYour widget key (begins with ca_). Public by design.
primaryColorThe button and header colour.
titleThe name in the chat header.
welcomeMessageThe first message a visitor sees.
positionbottom-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.

EntryAllows
yourshop.comThat domain and every subdomain of it (www.yourshop.com, shop.yourshop.com), on any port.
*.yourshop.comSubdomains only; add yourshop.com as well for the bare domain.
localhost:3000That host on that port only (for testing). localhost alone allows any port.
nullPages with no origin: local file:// pages and sandboxed frames.
  • Enter a domain without https:// or a path; the page removes them for you. http and https count as the same site.
  • Matching is by whole name: yourshop.com does not let in yourshop.com.other-site.net or myyourshop.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.

CodeHTTPMeaning
AUTH_REQUIRED401No widget key was sent.
INVALID_AUTH401The widget key is not a live key of an active company.
LEGACY_AUTH_RETIRED401An old snippet that sends your company name. Copy the snippet again.
NO_DOMAINS_CONFIGURED403Your allowed-domains list is empty.
ORIGIN_NOT_ALLOWED403The page is not on your allowed-domains list.
SHOPPER_TOKEN_REQUIRED401This browser's conversation could not be verified. Reloading the page fixes it.
RATE_LIMITED429Too many messages from one visitor.
QUOTA_EXCEEDED403Your chat credits are used up.
SALES_BUSY429Your 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_SUBSCRIPTION403Your company has no subscription.
SUBSCRIPTION_INACTIVE403Your subscription is not active.
METHOD_NOT_ALLOWED405Wrong method for this route.
INVALID_JSON400The body is not a JSON object.
EMAIL_REQUIRED400The visitor gave no email address.
EMAIL_INVALID400The email address was refused.
MESSAGE_REQUIRED400The message was empty.
AGENT_ERROR503The agent could not produce an answer. The visitor is shown an apology; retry after Retry-After seconds.
AGENT_FAILED503The 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_CONFIGURED or ORIGIN_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.