Skip to main content

Widget JavaScript API

The Woes loader exposes a queued browser API at window.Woes. Calls can be made after the install snippet is present; the loader queues commands until the widget runtime is ready. The embedded iframe also queues early commands until the inner widget API is installed, so early identify calls made during widget boot are not dropped.

Create The Queue Early

If your app may identify a user before https://woes.dev/widget.js has loaded, create the command queue first.
Then load the widget script with your public widget key.

Common Commands

Identify A Customer

Use identify when your application knows who the visitor is.
Unsigned identity is useful for display and routing, but it is not proof of identity. Any browser user can alter unsigned fields. For trusted history or account-specific context, use Widget Identity.

Verified Identity Pattern

For verified installs, your backend should expose an authenticated, no-store endpoint that returns the signed identity proof for the current logged-in user. Fetch it after login/session load, when widget.js loads, on window focus, and when the page becomes visible again. Calling identify more than once for the same current user is safe. Do not suppress retries for the same HMAC or JWT before Woes has accepted it.
For JWT mode, send { jwt: identity.jwt } instead. See Widget Identity for the server-side HMAC/JWT contract. For verified installs, call identify with the server-generated HMAC email hash or JWT before the visitor sends their first message.
If your application may call identify before widget.js finishes loading, create the queued API first.
Woes verifies HMAC/JWT proofs against the exact widget key installed on the page. In Settings → Security, select that agent and use Test an identity proof to confirm the backend output before testing a live chat.

Prefill Conversation Metadata

Use metadata fields to help operators understand the customer’s current page or workflow.
Do not send secrets, payment details, access tokens, or private customer data in client-side metadata.

Testing Checklist

  1. Load the page in a private browser window.
  2. Run window.Woes("show") from the browser console.
  3. If identity is enabled, confirm your identity endpoint returns Cache-Control: no-store and no private secret.
  4. Send a test message.
  5. Confirm the conversation appears in Woes Inbox.
  6. Confirm verified users appear with email/name and identity_source of widget-token.
  7. Confirm identity and metadata are shown only as intended.
Last modified on July 3, 2026