SDK

Install and drive Webchat from your application code.

npm install @assistifychat/widget
import { mount } from '@assistifychat/widget';
 
const widget = mount({ widgetId: 'WIDGET_ID' });
widget.chat.open();

Find your widget ID in the dashboard under Settings → Channels → Webchat → Install. The package is ESM-only.

mount() returns synchronously; methods called before the widget has booted are queued and replayed in order once it is ready. Outside the browser, mount() returns a no-op handle, so the same code can run during server-side rendering.

One widget runs per page. When widget.js is already on the page (rendered by <AssistifyScript>, a template or a pasted snippet), mount() uses that script and returns a handle wired to it, and the options below that shape the loader (baseUrl, autoload, launcher, identity) are not applied: set them where the script is rendered. mount() throws when that script carries a different widget ID.

Calling mount() again after destroy() brings the widget back in the same page session, useful for SPA routes that drop the widget and bring it back on a different page.

Using React? See React for AssistifyScript and useAssistify.

Options

OptionTypeDefault
widgetIdstringrequired
baseUrlstringhttps://assistify.chat
autoloadbooleantrueSee Deferred boot
launcherbooleantrueSet to false to render the panel without the floating launcher. See Panel-only.
identityWidgetIdentityIdentity sent with the boot request. See Identity verification.

An identity without a valid userHash is ignored at boot. When it carries customAttributes, the SDK also sends it through identify() once the widget has booted, which records it, unverified if it is not signed.

Full method and event list: JavaScript API.

Panel-only (custom launcher)

Set launcher: false to render the chat panel without the floating launcher, and open it from your own button or menu item:

const widget = mount({ widgetId: 'WIDGET_ID', launcher: false });
 
document.querySelector('#help').addEventListener('click', () => widget.chat.open());

The option applies to this embed only, so the same widget keeps its launcher on other pages. Combine it with autoload: false to hold all network activity until the first open. Closing the panel with the close button or the Escape key hides it completely, and you can listen for the close event when your button needs to reflect the open state.

Without the launcher, nothing else Webchat draws on the page shows either: campaign cards, including those shown with campaigns.show(), and the bubble of a conversation a teammate started. The Landing style keeps its bar on the page, since the bar is how it opens. A badge on your own button gets its count from unread:change, which fires when the count changes, not at boot.

Deferred boot

Pass autoload: false and the loader script is not injected at mount time. The handle is still returned synchronously, so the rest of your app can wire up event subscriptions without triggering any network activity.

const widget = mount({ widgetId: 'WIDGET_ID', autoload: false });
 
widget.events.on('ready', () => console.log('Widget is ready'));

Boot happens the first time your code calls one of these:

MethodTriggers boot?
chat.open() / chat.close() / chat.toggle()✅
load()✅
campaigns.show()✅
reset()❌ clears local visitor storage; boots only once the widget is on the page
events.on() / events.off()❌ buffered
user.identify()❌ buffered; the identity is included in the boot request
user.track()❌ buffered; sent once the widget boots
consent.set()❌ recorded at once, applied by the boot
user.getVisitorId() / consent.get()❌ read from storage directly
isReady()❌
destroy()❌ call it once the widget has loaded

Buffered calls reach the runtime on first boot in the order they were made.

user.track(), campaigns.show(), consent and the campaign events need @assistifychat/widget 1.2.0 or later.

const widget = mount({ widgetId: 'WIDGET_ID', autoload: false });
 
cmp.onConsentGranted('chat', () => {
  widget.load();
});

Nothing happens until consent is granted.

Boot when an identity becomes available

const widget = mount({ widgetId: 'WIDGET_ID', autoload: false });
 
auth.onSignIn(({ user, userHash }) => {
  widget.user.identify({ email: user.email, userHash });
  widget.load();
});

Identity supplied through user.identify() before boot is included in the boot request itself, so a signed visitor is verified when the widget first renders.

Tell your visitors

Your privacy policy should mention the chat. See Visitor recognition → Your privacy policy for the two notices to link.