15-day Pro trial · no credit cardStart free →

Web JS SDK

Methods

Reference for window.stingIm: show, hide, open, close, identify, logout, setTags, setContext, setStyle, getStatus, onReady and destroy.

All methods live on window.stingIm. Calls made before the widget's handshake completes are queued and delivered in order, so you can call them right after the install code runs.

Overview

MethodDescription
show()Show the widget and open the chat panel (undoes hide()).
hide()Hide the widget completely (launcher and panel). No proactive invitations pop up while hidden. Stays hidden until show() or open().
open()Open the chat panel. Also undoes hide().
close()Collapse the chat panel and keep the launcher.
identify(user)Declare or switch the logged-in user. Returns Promise<boolean>.
logout()The user logged out: clear the visitor session in this browser. Returns Promise<boolean>.
setTags(tags)Replace the entry tags set from JavaScript.
setContext({ product?, orderNo? })Business context passed to the agent. Replaces the previous context.
setStyle(css)Adjust position and stacking.
getStatus()Current state of the widget.
onReady(cb)Run cb(stingIm) when the widget is ready. Returns an unsubscribe function.
destroy()Remove the widget from the page.
versionHost protocol version (currently 2).

show, hide, open, close

JavaScript
stingIm.open();   // open the panel
stingIm.close();  // collapse to the launcher
stingIm.hide();   // remove launcher + panel from view
stingIm.show();   // bring it back and open the panel

hide() is a real hidden state: the widget cannot make itself visible again (for example to show a proactive invitation) until you call show() or open().

identify(user)

Declares the logged-in user or switches to a different one.

JavaScript
const ok = await stingIm.identify({
  userId: 'u_123',          // required, 1–255 characters, no control characters
  userHash: '9f86d0…',      // optional: 64 hex characters, computed on your server
  exp: 1767225600,          // optional: Unix seconds, only together with userHash
  name: 'Jane Doe',         // optional, display only, up to 64 characters
  email: '[email protected]' // optional, display only, up to 254 characters
});
  • Resolves true once the claim has been delivered to the widget, and false if the input is invalid (a console.warn explains why) or the widget was destroyed.
  • true does not mean the identity was verified. The backend's verdict arrives as the stingim:identity event and in getStatus().identityStatus.
  • A userHash that is present but not 64 hex characters rejects the whole claim (it is not downgraded to an unsigned claim). exp without userHash is invalid too.

See Identity verification for how to compute userHash.

logout()

JavaScript
await stingIm.logout();

Clears the visitor session stored in this browser so the next person starts as a fresh anonymous visitor. Call it when the user signs out of your site — especially on shared devices.

setTags(tags)

JavaScript
stingIm.setTags(['vip', 'kol_anna']);

Replaces the entry tags previously set from JavaScript (stingImSettings.tags or an earlier setTags). Up to 20 tags, each 1–64 characters; invalid entries are dropped. Tags drive routing rules configured in the console.

setContext(context)

JavaScript
stingIm.setContext({ product: 'Trail Runner 2 — size 42', orderNo: 'SO-10086' });

Business context for the conversation, for example when the visitor continues the chat on their phone. product is up to 200 characters, orderNo up to 64. Each call replaces the whole context; non-string fields are ignored.

setStyle(css)

JavaScript
stingIm.setStyle({ bottom: '90px', right: '24px', zIndex: '1000' });

Fine-tunes the widget's position and stacking. Only right, bottom, left, top, zIndex, maxWidth and maxHeight are accepted, as plain string values (letters, digits, spaces, . , % + -, at most 64 characters). Anything else is ignored with a console warning. Use show() / hide() for visibility. On phones the open panel is full-screen and your overrides apply again when it collapses.

getStatus()

JavaScript
stingIm.getStatus();
// { ready, visible, open, hidden, identityStatus, error, destroyed }
FieldMeaning
readyThe widget has finished initialising (visitor identity established) and can chat.
visibleThe widget is currently visible on the page.
openThe chat panel is open.
hiddenHidden by hide().
identityStatusVerdict of the latest identity claim: anonymous, verified, unverified or rejected; null if unknown.
errorReason for a fatal error (for example a rejected configuration); null normally.
destroyeddestroy() has been called.

onReady(cb)

JavaScript
const off = stingIm.onReady(function (api) {
  api.setTags(['returning']);
});
// off(); // cancel if it has not fired yet

Calls cb once the widget is ready. If it is already ready, cb runs asynchronously right away. You can also pass onReady in stingImSettings.

destroy()

JavaScript
stingIm.destroy();

Removes the iframe, event listeners and URL polling timer, restores the page title and deletes window.stingIm. Pending queued calls resolve with false. Afterwards you can insert the install code again. Removing only the <script> tag does not remove the widget — see Single-page apps.

Found a mistake? Email [email protected]