npm.io
1.0.32 • Published 5d ago

@supportwire/messenger-js-sdk

Licence
proprietary
Version
1.0.32
Deps
0
Size
2.4 MB
Vulns
0
Weekly
421

@supportwire/messenger-js-sdk

Drop-in replacement for @intercom/messenger-js-sdk that mounts a SupportWire widget.

Ships two ways with one identical signatureSupportWire(settings) to boot, plus methods (update, show, hide, shutdown, …):

  • Node module (bundler / npm) — import SupportWire from '…'.
  • CDN script tag (no build step) — load the IIFE; the same API lives on window.SupportWire.

Install

Node module (npm)

npm install @supportwire/messenger-js-sdk
import SupportWire from '@supportwire/messenger-js-sdk';

SupportWire({
  app_id: 'your-supportwire-widget-slug',
  user_id: currentUser.id,
  email: currentUser.email,
  user_hash: currentUser.supportwireHash,
  name: currentUser.name,
});

Importing the package has no side effects — nothing is registered until you call it. The default export can be imported under any name (see the Intercom migration diff below).

CDN (script tag)

Load the IIFE bundle. window.SupportWire exposes the same signature as the node module — call it with settings to boot, then use its methods:

<script src="https://assets.supportwire.ai/supportwire/widget.js"></script>
<script>
  SupportWire({
    app_id: 'your-supportwire-widget-slug',
    user_id: 'CURRENT_USER_ID',
    email: 'CURRENT_USER_EMAIL',
    user_hash: 'CURRENT_USER_HMAC',
  });
  // SupportWire.update({ email: 'new@example.com' });
  // SupportWire.show();  SupportWire.hide();  SupportWire.shutdown();
</script>

This is exactly the node-module API on windowSupportWire(settings) is the default export, SupportWire.update / .show / … are the named exports. Nothing Intercom-namespaced is touched, so it never collides with a real Intercom snippet on the same page.

Load the script synchronously (no async/defer) so window.SupportWire exists before your inline SupportWire({...}) call runs.

The bundle is also served from npm CDNs: https://unpkg.com/@supportwire/messenger-js-sdk / https://cdn.jsdelivr.net/npm/@supportwire/messenger-js-sdk.

If you're migrating an existing Intercom integration, default imports can be renamed at the import site — no other code change required:

- import Intercom from '@intercom/messenger-js-sdk';
+ import Intercom from '@supportwire/messenger-js-sdk';

  Intercom({
-   app_id: 'your-intercom-app-id',
+   app_id: 'your-supportwire-widget-slug',
    user_id: currentUser.id,
    email: currentUser.email,
-   user_hash: currentUser.intercomHash,
+   user_hash: currentUser.supportwireHash,
    name: currentUser.name,
  });

What's the app_id?

For SupportWire, app_id is your widget slug — the opaque, lowercase alphanumeric identifier shown next to each widget in the admin panel at /settings/widgets. Each widget is owned by one organization. Your backend resolves the org from the widget slug; you do not need to send a separate org identifier.

Identity & HMAC

When identity verification is enabled on your organization, send a user_hash computed server-side. The HMAC subject is user_id ?? email — i.e. when user_id is present it wins, otherwise the (lowercased, trimmed) email is signed.

import crypto from 'node:crypto';
const subject = currentUser.id ?? currentUser.email.trim().toLowerCase();
const userHash = crypto
  .createHmac('sha256', SUPPORTWIRE_HMAC_SECRET)
  .update(subject)
  .digest('hex');

Supported methods

Method Status
Intercom(settings) / boot(settings)
update(settings)
shutdown()
show() / hide()
showNewMessage(content?) (opens widget + sends content if supplied)
onShow(cb) / onHide(cb) / onUnreadCountChange(cb) / onUserEmailSupplied(cb)
getVisitorId() / whoami() returns null for now
trackEvent(name, metadata?) no-op + warn until backend endpoint ships
hideNotifications(hidden) no-op + warn
startTour / showArticle / showNews / startSurvey / startChecklist / showTicket / showConversation / showSpace / showMessages no-op + warn (no SupportWire equivalent)

Differences from Intercom

  • The product surface is smaller (no tours/articles/news/surveys). Those methods are silent no-ops so existing call sites don't throw.
  • getVisitorId() is synchronous in Intercom; ours returns null until an async fallback is added.
  • We never touch window.Intercom. The node module keeps its queue stub on window.SupportWireMessenger; the CDN build installs window.SupportWire. Both can coexist with a live Intercom snippet during migration.

Keywords