Web Widget API

Embed the BoostedChat widget on any page. Style every pixel with CSS custom properties and extend behaviour with a simple JavaScript API.

Quick Start #

Add this snippet to any HTML page to embed the widget. Replace YOUR_WIDGET_ID with the ID from your dashboard.

<!-- 1. Paste before </body> -->
<iframe
  src="https://boostedchat.com/widget?id=YOUR_WIDGET_ID&mode=contained"
  style="width:100%;height:600px;border:none;border-radius:24px;"
  allow="clipboard-write"
></iframe>

<!-- 2. (Optional) Customise after the iframe -->
<script>
  const frame = document.querySelector('iframe[src*="boostedchat"]');
  frame.addEventListener('load', () => {
    const BC = frame.contentWindow.BoostedChat;
    BC.style('--wg-primary', '#e11d48');
    BC.setTheme('dark');
    BC.on('message:send', (d) => console.log('User sent:', d));
  });
</script>

Embed Code #

The widget is served as an iframe. You control size, mode, and border-radius directly via URL params and inline styles.

URL Parameters

ParamRequiredDescription
idYesYour widget ID (from dashboard → Embed Code)
modeNocontained (default) — fixed height. integrated — auto-grows to fill content.

Sizes

SizeHeight
small500px
medium600px (default)
large720px
fullpage100vh

Integrated Mode (Auto-Resize)

When using mode=integrated, add this script after the iframe so it grows with content:

<script>
window.addEventListener('message', function(e) {
  if (e.data && e.data.type === 'boostedchat-widget-resize') {
    var iframe = document.querySelector('iframe[src*="boostedchat.com/widget"]');
    if (iframe) iframe.style.height = e.data.height + 'px';
  }
});
</script>

CSS Custom Properties #

Every visual aspect of the widget is driven by CSS custom properties on :root. Override them from outside the iframe via the JS API, or from inside via a <style> tag. All variables begin with --wg-.

Tip for AI agents: Call BoostedChat.getStyleMap() to get all 60+ variables with their current values as a JSON object. Then use BoostedChat.style(map) to apply your changes in one call.
Colors
VariableDefaultDescription
--wg-bg#ffffffWidget background
--wg-text#111827Primary text color
--wg-text-strong#000000Headings / strong text
--wg-text-dim#9ca3afDimmed / timestamp text
--wg-text-secondary#6b7280Secondary text
--wg-glass#f3f4f6Glass / frosted surface
--wg-glass-hover#e5e7ebGlass hover state
--wg-glass-border#e5e7ebGlass border color
--wg-glass-border-hover#d1d5dbGlass border hover
--wg-primary#6366f1Primary / brand color
--wg-primary-gradient#6366f1Secondary gradient stop
--wg-accent#6366f1Accent color for highlights
Message Bubbles
VariableDefaultDescription
--wg-user-bubble-bg#6366f1User message background
--wg-user-bubble-text#ffffffUser message text
--wg-ai-bubble-bg#f3f4f6AI message background
--wg-ai-bubble-text#111827AI message text
--wg-ai-bubble-border#e5e7ebAI message border
Layout & Spacing
VariableDefaultDescription
--wg-radius24pxWidget border-radius
--wg-msg-radius24pxMessage bubble radius
--wg-msg-gap12pxGap between messages
--wg-msg-max-width-user78%Max width of user bubbles
--wg-msg-max-width-ai90%Max width of AI bubbles
--wg-msg-padding12px 20pxPadding inside bubbles
--wg-area-padding16px 24pxPadding of the messages area
Input & Buttons
VariableDefaultDescription
--wg-input-bg#f9fafbInput background
--wg-input-text#111827Input text color
--wg-input-border#e5e7ebInput border color
--wg-input-shadow0 1px 3px rgba(0,0,0,0.06)Input box shadow
--wg-input-font-size16pxInput font size
--wg-input-padding20px 56pxInput padding
--wg-send-btn-bg#6366f1Send button background
--wg-send-btn-text#ffffffSend button icon color
--wg-send-btn-size38pxSend button diameter
Chips & Popovers
VariableDefaultDescription
--wg-chip-font-size12pxAction chip font size
--wg-chip-padding6px 14pxAction chip padding
--wg-chip-radius999pxAction chip border-radius
--wg-chip-gap5pxGap between chips
--wg-popover-radius16pxPopover border-radius
--wg-popover-padding16pxPopover inner padding
--wg-popover-shadow0 8px 32px rgba(0,0,0,0.12)Popover shadow
Typography
VariableDefaultDescription
--wg-font'Lexend', system-ui, sans-serifFont family
--wg-font-size15pxBase message font size
--wg-font-weight300Base font weight
--wg-line-height1.6Base line height
Glow & Effects
VariableDefaultDescription
--wg-glow-opacity0.12Background glow intensity
--wg-glow-color#6366f1Glow color (matches primary)
--wg-glow-blur28pxInput glow blur radius
--wg-glow-speed6sGlow animation cycle speed
Animations & Transitions
VariableDefaultDescription
--wg-anim-message-duration0.6sNew message entrance duration
--wg-anim-message-easingcubic-bezier(0.16,1,0.3,1)Message entrance easing
--wg-anim-message-distance10pxMessage slide-in distance
--wg-anim-typing-duration1.2sTyping dots animation cycle
--wg-anim-typing-dot-size7pxTyping dot diameter
--wg-anim-popover-duration0.2sPopover open/close speed
--wg-transition-fast0.15s easeFast transitions (hovers)
--wg-transition-normal0.2s easeNormal transitions
--wg-transition-slow0.3s easeSlow transitions
Miscellaneous
VariableDefaultDescription
--wg-branding-color#d1d5db"Powered by" text color
--wg-branding-link#9ca3af"Powered by" link color
--wg-scrollbar-colorrgba(0,0,0,0.1)Scrollbar thumb color
--wg-code-bg#f3f4f6Inline code background
--wg-code-color#6366f1Inline code text color

JavaScript API #

Access the API via iframe.contentWindow.BoostedChat. All methods are available after the iframe's load event.

Core Methods

registerAction(key, handler)
Register a custom action renderer. handler must have render(container, action) and optionally onConfirm(setParam, close, action).
setParam(key, value)
Set a hidden action parameter. Equivalent to the user selecting a value from a popover.
getParams() → Object
Returns the current hidden action parameters as a key-value object.
clearParams()
Clear all hidden action parameters.
sendMessage(text)
Send a message programmatically. If text is provided, it fills the input then sends.
getConfig() → Object
Returns the widget configuration object.
getSessionId() → string
Returns the current chat session ID.

Event Methods

on(event, callback)
Listen for an event. See Events for the full list.
off(event, callback)
Remove a previously registered event listener.

Style API #

Control every visual aspect of the widget at runtime. Set CSS variables, inject custom CSS, toggle themes, and manage body classes.

style(keyOrMap, value?)
Set one or many CSS custom properties. Pass a string + value, or an object of { variable: value } pairs.
// Single
BC.style('--wg-primary', '#e11d48');

// Batch
BC.style({
  '--wg-primary': '#e11d48',
  '--wg-radius': '8px',
  '--wg-font-size': '14px'
});
getStyle(property) → string
Get the current computed value of a CSS custom property.
getStyleMap() → Object
Returns all 60+ CSS custom properties and their current computed values as a { '--wg-*': 'value' } object.
resetStyle()
Remove all inline style overrides — revert to CSS defaults.
setTheme('light' | 'dark')
Switch between light and dark mode. Triggers theme:change event.
getTheme() → 'light' | 'dark'
Returns the current theme.
addCSS(css) → string (ruleId)
Inject raw CSS into the widget. Returns an ID you can pass to removeCSS().
const id = BC.addCSS(`.wg-msg-content { font-style: italic; }`);
// later: BC.removeCSS(id);
removeCSS(ruleId)
Remove a previously injected CSS rule by its ID.
addClass(className)
Add a CSS class to the widget <body> for conditional styling.
removeClass(className)
Remove a CSS class from the widget body.
hasClass(className) → boolean
Check if the widget body has a given CSS class.

Events #

Listen with BC.on(event, callback). All callbacks receive a data object.

Action Events

action:openPopover opened
action:confirmUser confirmed selection
action:paramHidden param set
message:sendMessage sent with params

UI Events

message:addedMessage rendered in chat
chip:clickAction chip tapped
popover:openAny popover opened
popover:closePopover dismissed
typing:showTyping dots appear
typing:hideTyping dots removed
input:focusInput textarea focused
input:blurInput textarea blurred
input:changeInput text changed

Style Events

style:changeCSS variable updated
style:resetStyles reverted to default
style:injectCustom CSS injected
theme:changeTheme switched

Event Data Examples

BC.on('message:send', (data) => {
  console.log(data.message);       // "I want to book for 2 adults"
  console.log(data.actionParams);   // { travelers: "2 Adults" }
});

BC.on('style:change', (data) => {
  console.log(data.property, data.value);  // "--wg-primary" "#e11d48"
});

BC.on('chip:click', (data) => {
  console.log(data.action);  // { label: "Pick Date", type: "date", ... }
});

Action Chips #

Action chips appear inside the chat input area. When a user clicks one, a popover opens with your configured UI (date picker, counter, dropdown, etc.). The selected value is sent as a hidden parameter alongside the next message.

Built-in Action Types

TypeDescriptionOutput Parameter
dateCalendar date pickerSelected date string
travelersAdults/children/infants counterFormatted traveler string
dropdownSingle-select dropdown listSelected option label
webhookFetches options from a URLSelected result
customDeveloper-rendered via registerAction()Whatever you set via setParam()

Custom Action Example

// Register a custom color picker action
BC.registerAction('colorPicker', {
  render: function(container, action) {
    container.innerHTML = '<input type="color" id="my-color">';
  },
  onConfirm: function(setParam, close, action) {
    const color = document.getElementById('my-color').value;
    setParam('selectedColor', color);
    close();
  }
});

Themes & Dark Mode #

The widget ships with light and dark themes. Dark mode activates when body.theme-dark is present. Toggle it with the API:

BC.setTheme('dark');   // switch to dark
BC.setTheme('light');  // switch to light
BC.getTheme();         // → 'dark' or 'light'

Dark Mode Overrides

When dark mode is active, these variables are automatically adjusted:

VariableDark Value
--wg-bg#05080f
--wg-textrgba(255,255,255,0.82)
--wg-glassrgba(255,255,255,0.06)
--wg-ai-bubble-bgrgba(255,255,255,0.06)
--wg-input-bgrgba(255,255,255,0.06)
--wg-glow-opacity0.22
Auto-detect user preference: Use window.matchMedia('(prefers-color-scheme: dark)').matches to automatically set the theme based on the user's OS setting.

CSS Selectors #

When you need more control than CSS variables provide, target these selectors via addCSS(). They are inside the widget iframe.

SelectorElement
.wg-inputThe main chat textarea
.wg-input-glowOuter glow ring around input
.wg-msg-contentMessage bubble container
.wg-messagesScrollable messages area
.wg-quick-action-btnAction chip button
.wg-send-btnSend button
.wg-action-popoverAction popover container
body.theme-darkWidget in dark mode

Keyframe Animations

AnimationUsed For
wgAppearMessage entrance (slide + fade)
wgGlowRotateStatic glow pulse
wgGlowAnimatedHue-rotate glow cycle
wgDotBounceTyping indicator dots

Recipes #

Copy-paste examples for common customisations.

Match Your Brand

const BC = iframe.contentWindow.BoostedChat;

BC.style({
  '--wg-primary'        : '#e11d48',
  '--wg-accent'         : '#e11d48',
  '--wg-user-bubble-bg' : '#e11d48',
  '--wg-send-btn-bg'    : '#e11d48',
  '--wg-glow-color'     : '#e11d48',
  '--wg-font'           : "'Inter', sans-serif",
  '--wg-radius'         : '12px',
  '--wg-msg-radius'     : '12px',
});

Auto Dark Mode

iframe.addEventListener('load', () => {
  const BC = iframe.contentWindow.BoostedChat;
  const prefersDark = window.matchMedia('(prefers-color-scheme: dark)');

  BC.setTheme(prefersDark.matches ? 'dark' : 'light');

  prefersDark.addEventListener('change', (e) => {
    BC.setTheme(e.matches ? 'dark' : 'light');
  });
});

Minimal Flat Style

BC.style({
  '--wg-radius'         : '0px',
  '--wg-msg-radius'     : '4px',
  '--wg-glow-opacity'   : '0',
  '--wg-input-shadow'   : 'none',
  '--wg-input-border'   : '#d1d5db',
  '--wg-popover-shadow' : 'none',
});

Slow, Cinematic Animations

BC.style({
  '--wg-anim-message-duration' : '1.2s',
  '--wg-anim-message-distance' : '24px',
  '--wg-anim-message-easing'   : 'cubic-bezier(0.22, 1, 0.36, 1)',
  '--wg-transition-fast'       : '0.3s ease',
  '--wg-transition-normal'     : '0.5s ease',
  '--wg-glow-speed'            : '12s',
});

Log All Events (Debug)

const events = [
  'message:send', 'message:added', 'chip:click',
  'popover:open', 'popover:close',
  'typing:show', 'typing:hide',
  'input:focus', 'input:blur', 'input:change',
  'style:change', 'theme:change'
];

events.forEach(ev =>
  BC.on(ev, (d) => console.log(`[BC] ${ev}`, d))
);