SupportWire API
Chat Widget

JavaScript API

Control the widget programmatically — methods, callbacks, and the messenger SDK.

Loader instance

new SupportWireWidget({ … }) returns an instance with these methods:

MethodSignatureDescription
open()() => voidOpen the widget.
close()() => voidClose the widget.
toggle()() => voidToggle open/closed.
showTrigger()() => voidShow the launcher button.
hideTrigger()() => voidHide the launcher button.
updateConfig(config)(config: Partial<Config>) => voidUpdate options at runtime.
sendMessage(message, options?)(message: string, options?: { openWidget?: boolean }) => voidPre-fill/send a message. Opens the widget unless openWidget: false.
destroy()() => voidRemove the widget, clear its local state, and detach listeners.
SupportWireWidget.getInstances(slug?)(slug?: string) => SupportWireWidget[]All instances, optionally filtered by slug.
const widget = new SupportWireWidget({ widgetSlug: 'YOUR_WIDGET_SLUG' });

document.querySelector('#help').addEventListener('click', () => widget.open());

Callbacks

Pass these in the config:

CallbackFires when
onOpenThe widget opens.
onCloseThe widget closes.
onErrorAn error occurs during init or operation.

Messenger SDK

The npm SDK (@supportwire/messenger-js-sdk) exposes an Intercom-compatible API.

MethodDescription
boot(settings)Initialize with full settings.
update(settings)Update settings on a running instance.
show() / hide()Open / close the messenger.
showNewMessage(content?)Open with an optional pre-filled message.
shutdown()Tear down and clear local state.
onShow(cb)Subscribe to open events. Returns an unsubscribe function.
onHide(cb)Subscribe to close events. Returns an unsubscribe function.
onUnreadCountChange(cb)Subscribe to unread-count changes (delivers current count immediately).
onUserEmailSupplied(cb)Fires when an email is supplied via boot/update.
trackEvent(name, metadata?)Track a custom event.
import SupportWire, { onUnreadCountChange, show } from '@supportwire/messenger-js-sdk';

SupportWire({ app_id: 'YOUR_WIDGET_SLUG' });

onUnreadCountChange((count) => {
  document.title = count > 0 ? `(${count}) Support` : 'Support';
});

Pre-boot queue

If you load the SDK asynchronously, queue calls on window.SupportWireMessenger before it loads — they drain once it's ready:

window.SupportWireMessenger = window.SupportWireMessenger || function (...a) {
  (window.SupportWireMessenger.q = window.SupportWireMessenger.q || []).push(a);
};

window.SupportWireMessenger('boot', { app_id: 'YOUR_WIDGET_SLUG' });
window.SupportWireMessenger('show');

Some Intercom methods are not yet implemented and are safe no-ops: startTour, showArticle, showNews, startSurvey, startChecklist, showTicket, showConversation, showSpace, showMessages, hideNotifications.

On this page