Widget Embed Guide
The widget is a Web Component (<web-chat-agent>) that loads asynchronously and runs on any site — no framework, no build step. The script renders a floating chat button; visitors click it to open the chat window.
Embed Code
Paste this right before the closing </body> tag:
<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 Chatbot ID, found in Dashboard → Chatbot → Widget Customization, where the embed code is pre-filled with your ID. Copy it from there to avoid typos.
The widget calls the API on the same origin it was loaded from. Load the script from app.webchatagent.com and the chat requests go to app.webchatagent.com/api/... automatically — you never configure an API URL by hand.
How It Works
- The
asyncscript loads in the background and does not block page rendering. - The
<web-chat-agent>element renders a floating chat button. - The widget fetches your dashboard settings (colors, texts, tools, welcome message) and applies them. No extra attributes needed.
- A visitor clicks the button, the chat window opens, and messages go to your AI chatbot.
HTML Attributes
Every visual setting from the Widget Customization page is applied automatically. HTML attributes on the element are optional overrides — use them only for per-page tweaks (e.g. a different position on one landing page). Attribute names are kebab-case (the widget maps theme-color to the themeColor prop internally).
Defaults below are the widget's built-in fallbacks. In practice most attributes are left unset and inherit the value you configured in the dashboard.
Basic Settings
| Attribute | Type | Default | Description |
|---|---|---|---|
chatbot-id | string | — | Required. Your Chatbot ID (UUID). |
theme | string | default | Widget theme: default or modern. |
title | string | from translations | Title shown in the chat header. |
initially-open | boolean | false | Open the chat window automatically on page load. |
width | number | CSS default | Chat window width in pixels. If unset, the responsive default applies. |
height | number | CSS default | Chat window height in pixels. If unset, the responsive default applies. |
font-family | string | inherit | Google Font name (e.g. Roboto, Open Sans); loaded automatically. If unset, inherits the page font. |
Colors
All color attributes accept any valid CSS color (hex like #2563eb, rgb(), hsl()). When unset, the widget uses your dashboard value or its built-in fallback (the brand default is blue, #2563eb).
| Attribute | Description |
|---|---|
theme-color | Header and accent background color. |
theme-text-color | Header text color. |
bot-message-color | Bot message bubble background. |
bot-message-text-color | Bot message text color. |
user-message-color | User message bubble background. |
user-message-text-color | User message text color. |
bubble-color | Floating chat button background. |
bubble-text-color | Floating chat button icon color. |
Images
| Attribute | Description |
|---|---|
avatar-src | URL to an avatar image shown in the chat header. |
chat-bubble-image | URL to a custom image for the floating chat button (replaces the default icon). |
welcome-image | URL to an image shown above the welcome message (e.g. a company logo). |
Positioning
| Attribute | Type | Default | Description |
|---|---|---|---|
offset-x | number | 20 | Horizontal offset from the right edge (desktop), in pixels. |
offset-y | number | 20 | Vertical offset from the bottom edge (desktop), in pixels. |
mobile-offset-x | number | 20 | Horizontal offset from the right edge (mobile), in pixels. |
mobile-offset-y | number | 20 | Vertical offset from the bottom edge (mobile), in pixels. |
Content & Behavior
| Attribute | Type | Default | Description |
|---|---|---|---|
welcome-message | string | from config | HTML welcome message shown when the chat opens. |
speech-bubble-text | string | none | HTML text for the speech bubble next to the chat button. If unset, no bubble appears. |
privacy-policy-html | string | none | HTML block (bold, links) for a privacy notice inside the widget. |
disable-voice-input | boolean | false | Hide the microphone / voice input button. |
hide-branding | boolean | false | Hide the "Powered by WebChatAgent" link (paid plans only). |
lang-detection-source | string | browser | How the widget picks its UI language: browser (navigator language) or html (reads <html lang="...">). |
Prompt Buttons
Quick-action buttons rendered under the message list. Each button has a visible title and an action (the text sent as the user's message when clicked). Pass a JSON array as the attribute value:
<web-chat-agent
chatbot-id="YOUR_CHATBOT_ID"
prompt-buttons='[{"title":"Talk to support","action":"I need help with my order"},{"title":"Pricing","action":"What does it cost?"}]'
></web-chat-agent>
| Attribute | Type | Description |
|---|---|---|
prompt-buttons | JSON | Array of { "title": string, "action": string }. A non-empty value overrides buttons configured in the dashboard. |
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
Dashboard settings are stored server-side and loaded when the widget initializes. HTML attributes override them for that page only.
Recommendation: Do all visual customization in the dashboard. Reach for HTML attributes only when one page needs to differ — different positioning, a forced theme, or page-specific prompt buttons.
Custom CSS
For changes that go beyond the attributes above, target the widget's internal elements with your own CSS. Every styleable element carries a stable .wca-* class (for example .wca-header, .wca-message, .wca-bubble), so your selectors keep working across widget updates and don't need !important. You add the CSS in the dashboard, and it is injected into the widget's shadow DOM. See Custom CSS.
Inline Widget
To render the chat inside your page layout instead of as a floating button, use the inline variant. It loads a different script and a different element (<web-chat-agent-inline>):
<script src="https://app.webchatagent.com/widget/chat-widget-inline.js" async></script>
<web-chat-agent-inline chatbot-id="YOUR_CHATBOT_ID"></web-chat-agent-inline>
The inline element takes only chatbot-id; all other settings come from its own dashboard configuration. Place the element wherever you want the chat to appear, and size it with the surrounding container. See Inline Widget for details.
WordPress
On WordPress, use the official WebChatAgent WordPress Plugin instead of pasting the script manually. It handles the embed and updates for you. See WordPress Plugin.
Single Page Applications (SPA)
The widget works with React, Vue, Angular, and other SPAs out of the box. Add the script tag to index.html and place the <web-chat-agent> element in your app shell (e.g. the root layout). The widget persists across client-side route changes — you do not re-mount it on navigation.
