Website Chat Widget
Embed the chat widget, control where it sits, how it looks and when it opens, and know who is chatting
One script tag puts a live chat button on every page of your site. From there you can move it, restyle it, or replace it entirely with a button of your own — including one inside a menu you already have. It can also offer your other channels first, ask visitors for their details, or be told who is signed in (section 6).
1. Paste the tag
Add this once, just before the closing </body> tag of your site's layout or
template. Every page using that layout gets the chat button.
<script
src="https://<your-domain>/app/api/web-chat/widget-js?widgetId=<your-widget-id>"
async
></script>Your widget ID is in the dashboard under Web Widgets — the Embed snippet box already has it filled in, so you can copy the whole line from there.
If Allowed origins is set on your widget, your site's address has to be on that list or the chat will not load. Leave the list empty to allow any site.
2. Move and size the widget
By default the launcher is a 56px circle in the bottom-right corner, 24px from each edge. If something is already there — a cookie banner, a back-to-top arrow, your own support menu — move it, and size it to match the buttons you already have.
You can set this in three places, and the more specific one wins:
| Set it | Applies to | |
|---|---|---|
| 1 | window.FastcomChat.setPlacement(…) | the moment you call it |
| 2 | data-* attributes on the <script> tag | that page |
| 3 | Web widgets → Placement in the dashboard | every page, unless overridden |
From the dashboard
Pick a corner and the spacing from each edge. This is the right place for it if the widget should sit in the same spot across your whole site — no code change, and it takes effect on the next page load.
From the embed tag
To place it differently on one particular page:
<script
src="https://<your-domain>/app/api/web-chat/widget-js?widgetId=<your-widget-id>"
data-position="bottom-left"
data-offset-y="96"
data-size="72"
async
></script>| Attribute | Values | Default |
|---|---|---|
data-position | bottom-right, bottom-left, top-right, top-left | bottom-right |
data-offset-x | Space from the left or right edge, 0–200px | 24 |
data-offset-y | Space from the top or bottom edge, 0–200px | 24 |
data-size | Diameter of the button, 40–120px | 56 |
data-width | Width of the chat window, 280–560px | 360 |
data-height | Height of the chat window, 320–800px | 520 |
data-unread-badge | hidden leaves the unread count to your own indicator (section 7) | shown |
Any attribute you leave out falls back to your dashboard setting. An attribute you do set is pinned: the dashboard cannot move it afterwards.
From CSS
The widget's stylesheet is deliberately the first thing in <head>, so your
own CSS always wins — no !important needed. The spacing is exposed as custom
properties, so it can respond to your breakpoints like anything else:
:root {
--ascend-wc-offset-x: 40px;
--ascend-wc-offset-y: 120px;
--ascend-wc-size: 72px; /* diameter of the launcher */
--ascend-wc-panel-width: 420px; /* size of the chat window */
--ascend-wc-panel-height: 640px;
--ascend-wc-z: 999; /* stacking order, if the widget must sit under something */
}
@media (max-width: 640px) {
:root {
--ascend-wc-offset-y: 72px; /* clear the mobile tab bar */
}
}On computers, the chat window opens at the launcher's corner and spacing. The launcher hides while the window is open and returns when the window closes. The icon inside the launcher scales with the button.
Sizing the chat window
The window is 360×520 by default. Give it more room for a long form or a product
configurator, or less if it has to fit a narrow layout — from the dashboard, the
data-width and data-height attributes above, the custom properties above, or
at runtime:
FastcomChat.getPanelSize(); // → { width: 360, height: 520 }
FastcomChat.setPanelSize({ height: 680 }); // either key, or bothThe window stays within the browser on computers. On screens up to 480px wide, the chat fills the visible viewport and resizes when the keyboard opens.
The two elements are #ascend-wc-bubble (the launcher) and #ascend-wc-panel
(the chat window). Both carry a data-pos attribute with the current corner, so
you can style against it:
#ascend-wc-bubble[data-pos='bottom-left'] {
box-shadow: 4px -4px 14px rgba(0, 0, 0, 0.25);
}3. Use your own button
If you already have a support menu — one that fans out into Messenger, WhatsApp, a phone number — the chat usually belongs inside it rather than floating as a second bubble beside it.
data-launcher="hidden" keeps our launcher hidden while your own button opens
the chat window at the configured placement.
<script
src="https://<your-domain>/app/api/web-chat/widget-js?widgetId=<your-widget-id>"
data-launcher="hidden"
async
></script>
<button onclick="FastcomChat.open()">Chat with us</button>FastcomChat.open() is safe to call at any time, including before the script has
finished loading — the widget remembers the request and opens as soon as it is
ready.
Prefer the attribute to hiding the button from script: it is decided before anything is drawn, so there is no moment where our bubble is visible.
4. React and Next.js
One thing to know before writing the component: the widget is a plain script that
mounts itself into document.body. It is not part of your component tree,
and removing the tag does not unload it. So load it once, and control it through
window.FastcomChat for the rest of the page's life.
Load with the page
The chat opens instantly when someone asks for it. The usual choice.
'use client';
import { useEffect } from 'react';
const SRC =
'https://<your-domain>/app/api/web-chat/widget-js?widgetId=<your-widget-id>';
const SCRIPT_ID = 'fastcom-chat';
export function ChatButton() {
useEffect(() => {
// Guard the id. In development React runs this twice, and two copies of
// the widget would fight over the same elements.
if (document.getElementById(SCRIPT_ID)) {
window.FastcomChat?.show();
return;
}
const script = document.createElement('script');
script.id = SCRIPT_ID;
script.src = SRC;
script.dataset.launcher = 'hidden'; // we open it from our own button
script.async = true;
document.body.appendChild(script);
// Optional: take the chat off pages it does not belong on.
return () => window.FastcomChat?.hide();
}, []);
return (
<button onClick={() => window.FastcomChat?.open()}>Chat with us</button>
);
}Load on first click
Nothing is downloaded and no connection is opened until a visitor actually wants to chat — worth it on a landing page where most people never will.
export function ChatButton() {
const openChat = () => {
if (window.FastcomChat) return window.FastcomChat.open();
const script = document.createElement('script');
script.src = SRC;
script.dataset.launcher = 'hidden';
script.async = true;
script.onload = () => window.FastcomChat.open();
document.body.appendChild(script);
};
return <button onClick={openChat}>Chat with us</button>;
}hide() or destroy()?
hide()takes the widget off the page but keeps it loaded: the visitor's conversation stays, the live connection stays up, andshow()brings it straight back. Use it for a component that comes and goes with navigation.destroy()unloads it completely — elements, stylesheets, the live connection andwindow.FastcomChatitself. Use it when the widget should genuinely not be running: a page it does not belong on, a logged-out state. The conversation is not lost (it lives in the visitor's browser), and loading the script again restores it.
After destroy(), window.FastcomChat is gone, so re-mounting means injecting
the script again — check for the global rather than the tag id when you do.
5. Light or dark
Your brand colour paints the launcher, the header and your visitor's own messages. The rest of the panel — its background, the bot's message bubbles, the input — comes from a light or a dark palette.
Which one it uses is the Chat window setting on the widget:
- Match the visitor (default) — uses your site's dark mode if it sets a
darkclass on<html>, and otherwise follows the visitor's device. Right for a site that has its own dark mode. - Always light / Always dark — pins the panel. Pick one if your site is light-only or dark-only. Otherwise a visitor whose laptop is in dark mode sees a dark chat window on your light page, which usually looks like a fault.
Per page, from the tag or at runtime:
<script src="…" data-theme="light" async></script>FastcomChat.getTheme(); // → 'auto' | 'light' | 'dark'
FastcomChat.setTheme('dark'); // e.g. alongside your own theme switchSetting the colours yourself
Each palette is built from variables you can set on :root. Set only the ones
you want to change — anything you leave alone keeps its default. The light- set
applies when the panel is light, the dark- set when it is dark, so you can
style both and let the theme decide:
:root {
--ascend-wc-light-surface: #ffffff; /* panel background */
--ascend-wc-light-fg: #222222; /* text */
--ascend-wc-light-bot-bg: #f0f0f0; /* the bot's message bubbles */
--ascend-wc-light-bot-fg: #222222;
--ascend-wc-light-input-bg: #ffffff;
--ascend-wc-light-input-border: #dddddd;
--ascend-wc-light-border: #eeeeee;
--ascend-wc-light-muted: #9ca3af;
--ascend-wc-dark-surface: #11221b;
--ascend-wc-dark-fg: #e5f0e1;
--ascend-wc-dark-bot-bg: #142a22;
/* …the same names with a dark- prefix */
}These are the supported hook for panel colours. Overriding --ascend-wc-surface
directly works only in light mode — the dark rules set it themselves, and would
win.
6. Tell us who the visitor is
There are two ways for a chat to arrive with a name, email or phone number attached. You can use either, both, or neither.
The pre-chat form
Turn it on in Web widgets → Visitor identity → Pre-chat form. Opening the website chat first shows a short form, and the chat opens once it is submitted. Choose which of name, phone and email it asks for. Each one can be required, optional or hidden, and at least one of phone or email must be required. There is no skip button. A visitor who has filled it in once is not asked again on that browser.
Signed-in users on your site
If your website knows who is logged in, pass their details to the widget after login, or on every page load while they are logged in:
FastcomChat.identify({
email: 'rahim@example.com',
name: 'Rahim Uddin', // optional
phone: '+8801712345678', // optional
userId: 'cust_8812', // optional: your own id for this user
userHash: '<from your server>', // only needed with verification on
});
// On logout: a new anonymous visitor, with an empty chat. A verified user
// gets their conversation back when they sign in again.
FastcomChat.reset();identify() needs an email or a phone. Calling it again with the same details
does nothing, so it is safe on every page load. If a different user (by
userId, else email) is identified on the same browser, the widget resets
first, so the next person on a shared computer never sees the last one's
conversation.
Sites that render on the server can declare the same thing before the embed tag instead:
<script>
window.FastcomChatSettings = {
identity: { email: 'rahim@example.com', name: 'Rahim Uddin' },
};
</script>
<script src="https://…/api/web-chat/widget-js?widgetId=…" async></script>If the form is on and the site has already given us some of its fields, the form asks only for the rest.
Verification. Anyone can call identify() from the browser console with any
email, so by default the inbox labels these details "From site" (unverified).
To prove them, have your server compute
userHash = HMAC-SHA256(identity secret, userId) // hexand pass both userId and userHash. The identity secret is under Web
widgets → Visitor identity, with ready-made Node, PHP and Python snippets.
Keep it on your server, never in page code. Switch on Require verified
identity to refuse any identify() call without a valid hash.
A verified user always comes back to the same conversation. After a logout,
after someone else used the same browser, or on another device, the widget
switches to that user's conversation and shows its recent history, and the
inbox keeps one contact for them. Unverified details never do this: an email,
or a userId without a valid hash, only ever starts a new conversation.
If a visitor chats anonymously and then signs in as a verified user who already has a conversation, the widget moves to that conversation. The anonymous chat stays in the inbox as its own contact.
The channel menu
Turn it on in Web widgets → Channel menu. Clicking the launcher then asks
"How can we help?", with a button for each channel you add: the website chat,
plus Messenger, WhatsApp and Instagram links. Those three open the app (a new
tab on a computer), and the conversation arrives in your inbox through that
channel as usual. With the menu on, FastcomChat.open() shows the menu and
FastcomChat.open({ view: 'chat' }) goes straight to the chat.
7. Unread replies and message status
Show your own unread indicator
The widget counts replies the visitor has not seen yet. That includes replies that arrived while the visitor had no tab open: the widget catches up as soon as the page loads, whether or not the chat is opened. A reply counts as seen once the chat window was open on a visible tab while it was showing.
FastcomChat.getUnreadCount(); // a number
// Called straight away with the current count, then on every change.
const stop = FastcomChat.onUnreadCountChange((count) => {
myBadge.textContent = count > 0 ? String(count) : '';
});
stop(); // unsubscribe
// The same count as a window event, for code that runs before the widget has loaded.
window.addEventListener('fastcomchat:unread', (event) => {
console.log(event.detail.count, event.detail.widgetId);
});Our launcher shows the count as a small badge. If you draw your own, turn ours off on the embed tag:
<script
src="https://<your-domain>/app/api/web-chat/widget-js?widgetId=<your-widget-id>"
data-unread-badge="hidden"
async
></script>What the visitor sees
- Times. Each run of messages shows when it was sent, with a separator for each day ("Today", "Yesterday", or a date) in the visitor's own language and time zone.
- Delivered and Seen. The visitor's latest message shows "Delivered" once it reaches us, and "Seen" once someone on your team has opened the conversation. A reply from your AI agent does not count as seen. In your inbox, each of your messages shows whether the visitor has received it and whether they have seen it.
- Failed messages. A message that could not be sent is marked "Not sent. Tap to retry." When the visitor is offline it waits, and is sent automatically when the connection comes back. A retry never creates a second copy of a message that did arrive.
- Typing. The typing bubble appears only when your AI agent has the message and is going to reply, and for at most a minute.
You can also show or hide it from your own system with the Messaging API's
typing_onandtyping_offactions. - Several tabs. Every tab of your site shows the same conversation, and a logout in one tab (
reset()) clears all of them. - Long conversations. The newest 30 messages show first, and older ones load as the visitor scrolls up.
Reference
Everything below is available on window.FastcomChat as soon as the script has
run. Calls made before the widget has finished rendering are applied when it
does, so you never have to wait for it.
| Method | What it does |
|---|---|
open() | Opens the chat window (the channel menu, when that is on) |
open({ view: 'chat' }) | Opens straight to the chat, skipping the channel menu |
close() | Closes it |
toggle() | Opens or closes it |
isOpen() | Returns true or false |
showLauncher(false) | Hides our floating button, keeping the chat usable from yours |
isLauncherVisible() | Whether our button is showing |
hide() | Takes the widget off the page, keeping the conversation and connection |
show() | Brings it back |
destroy() | Unloads it completely |
getTheme() / setTheme('dark') | light, dark or auto |
getPlacement() | Where the launcher is now |
setPlacement({…}) | Moves and sizes it: { position, offsetX, offsetY, size }, any subset |
getPanelSize() | The chat window's size on desktop |
setPanelSize({…}) | Resizes it: { width, height }, either key |
identify({…}) | Tells us who the visitor is: { email, phone, name, userId, userHash } |
reset() | Starts over as a new anonymous visitor, e.g. on logout |
getUnreadCount() | Replies the visitor has not seen yet |
onUnreadCountChange(fn) | Calls fn(count) now and on every change; returns an unsubscribe function |
widgetId | The id this embed is serving |
Values outside the accepted set are ignored rather than throwing, so a bad value can never take down the page the widget is embedded in.
// Grow the button on wide screens, shrink it on narrow ones.
FastcomChat.setPlacement({ size: window.innerWidth > 900 ? 72 : 52 });
// Lift the button while a cookie banner is up, then drop it back.
FastcomChat.setPlacement({ offsetY: 96 });
banner.addEventListener('dismiss', () =>
FastcomChat.setPlacement({ offsetY: 24 }),
);Common mistakes
- Rendering the script tag conditionally. Adding and removing the tag does not unload the widget. The first embed to run starts the chat, and later copies leave it running. In React, keep the script tag's ID check to avoid inserting the tag again when a component remounts.
- Expecting the widget inside your component's markup. It attaches to
document.bodyand positions itself against the browser window, so it cannot be nested inside your own layout. Control it throughFastcomChatinstead. - Leaving your domain off the allowed origins list. The chat will load nothing and log a message to the browser console explaining exactly this.
Notes
- Mobile. At 480px wide or less, chat opens full screen with the header at the top and the message input above the keyboard. The launcher still honours your placement and size.
- Conversations persist in the visitor's own browser and on our side, so someone who refreshes or comes back later sees their history, including replies sent while they were away. A signed-in visitor with a verified identity also gets it on other devices.