Widget Embed Guide

Embed the WebChatAgent chatbot widget on any website. The widget is a Web Component (<web-chat-agent>) that loads asynchronously and works on any site — no framework required.

Embed Code

Add the following code before the closing </body> tag of your website:

<script src="https://app.webchatagent.com/widget/web-chat-agent.js" async></script>
<web-chat-agent
  chatbot-id="YOUR_CHATBOT_ID"
></web-chat-agent>

Replace YOUR_CHATBOT_ID with your actual Chatbot ID. You can find it in Dashboard → Chatbot → Widget Customization at the bottom of the page, where the embed code is pre-filled with your ID.

Tip: You can also copy the ready-to-use embed code directly from the Widget Customization page in your dashboard.

How It Works

  1. The script loads your widget asynchronously (does not block page rendering)
  2. The <web-chat-agent> custom element renders a floating chat button on your page
  3. All widget settings (colors, texts, tools) configured in the dashboard are automatically applied — no extra attributes needed
  4. Visitors click the button to open the chat window and interact with your AI chatbot

HTML Attributes

All visual settings from the Widget Customization page in the dashboard are applied automatically. However, you can override them via HTML attributes on the <web-chat-agent> element:

Basic Settings

AttributeTypeDefaultDescription
chatbot-idstringRequired. Your Chatbot ID
themestringdefaultWidget theme: default or modern
titlestringCustom title displayed in the chat header
initially-openbooleanfalseOpen the chat window automatically on page load
widthnumber440Chat window width in pixels (300–600)
heightnumber700Chat window height in pixels (300–700)
font-familystringGoogle Font name (e.g. Roboto, Open Sans). Loaded automatically

Colors

All color attributes accept hex values (e.g. #2563eb).

AttributeDefaultDescription
theme-color#ffffffHeader background color
theme-text-color#000000Header text color
bot-message-color#f3f4f6Bot message bubble background
bot-message-text-color#424242Bot message text color
user-message-color#2563ebUser message bubble background
user-message-text-color#ffffffUser message text color
bubble-color#424242Floating chat button background
bubble-text-color#ffffffFloating chat button icon color

Images

AttributeDescription
avatar-srcURL to an avatar image displayed in the chat header
chat-bubble-imageURL to a custom image for the floating chat button (replaces the default icon)

Positioning

AttributeTypeDefaultDescription
offset-xnumber20Horizontal offset from right edge (desktop), in pixels
offset-ynumber20Vertical offset from bottom edge (desktop), in pixels
mobile-offset-xnumber20Horizontal offset from right edge (mobile), in pixels
mobile-offset-ynumber20Vertical offset from bottom edge (mobile), in pixels

Content & Behavior

AttributeTypeDescription
welcome-messagestringHTML welcome message shown when the chat opens
speech-bubble-textstringHTML text for the speech bubble next to the chat button
privacy-policy-htmlstringHTML block for a privacy policy notice inside the widget
disable-voice-inputbooleanDisable the microphone/voice input button
hide-brandingbooleanHide "Powered by WebChatAgent" branding (paid plans only)
lang-detection-sourcestringLanguage detection: browser (default) or html (reads <html lang="...">)

Prompt Buttons

AttributeTypeDescription
prompt-buttonsJSONArray of quick-action buttons: [{"title":"Help","action":"I need help"}]

Example: Full Customization

<script src="https://app.webchatagent.com/widget/web-chat-agent.js" async></script>
<web-chat-agent
  chatbot-id="abc-123-def"
  theme="modern"
  title="Support Chat"
  theme-color="#4f46e5"
  theme-text-color="#ffffff"
  user-message-color="#4f46e5"
  bubble-color="#4f46e5"
  font-family="Inter"
  initially-open="false"
  offset-x="30"
  offset-y="30"
></web-chat-agent>

Dashboard vs. HTML Attributes

Settings configured in the Widget Customization page in the dashboard are stored server-side and applied automatically when the widget loads. HTML attributes on the <web-chat-agent> element will override the dashboard settings.

Recommendation: Use the dashboard for all visual customization. Only use HTML attributes if you need per-page overrides (e.g. different positioning on a specific landing page).

WordPress

For WordPress sites, use the official WebChatAgent WordPress Plugin instead of manual embedding. See the WordPress Plugin documentation.

Single Page Applications (SPA)

The widget works with SPAs (React, Vue, Angular, etc.) out of the box. Add the script tag to your index.html and place the <web-chat-agent> element in your app shell. The widget persists across client-side route changes.