Warmly Widget Client-Side JS API

Last updated: November 23, 2026

Before you start: the JS API ships with the Warmly script. If the script is on your site, window.warmly is already there. No extra install, no API key.

The Warmly JS API lets your website talk to the Warmly widget. Open or close the chat, grab the Warmly session ID for your analytics tools, and react the moment a visitor is identified.

Every call has the same shape:

warmly('methodName', argument)

Methods at a Glance

Method

What it does

Returns

show

Opens the chat panel

—

hide

Closes the chat panel (the launcher bubble stays on the page)

—

makeWidgetFullScreen

Toggles the chat panel between full screen and normal size

—

addSessionIdListener

Runs your callback once when the Warmly session ID is ready

Listener ID

removeSessionIdListener

Cancels a session ID listener that's still waiting for the session to be created

—

addSessionIdentifiedListener

Runs your callback when the visitor is identified, and again whenever that identification changes

Listener ID

removeSessionIdentifiedListener

Stops an identified listener

—

Anything not in this table isn't supported. Calling an unknown method throws Method <name> is not supported.

Where to Put Your Code

The Warmly script tag uses defer, so it runs after the page's HTML has been parsed. Plain inline scripts run before it, even when they come after the Warmly tag. Put your Warmly calls in a DOMContentLoaded handler (or any code that runs later, like a click handler):

document.addEventListener('DOMContentLoaded', function () {
  warmly('addSessionIdListener', function (sessionId) {
    // ...
  })
})

Listeners can be registered right away. From DOMContentLoaded onwards, addSessionIdListener and addSessionIdentifiedListener work even if the widget is still loading. Warmly holds the calls and registers them in order as soon as it's ready.

Panel methods are for visitor actions. Call show, hide and makeWidgetFullScreen in response to something the visitor does, such as clicking your "Talk to us" button, once the widget is on the page.

One catch: a listener registered before the widget loads can't return a listener ID. You get undefined back instead, and the callback still fires normally. Since there's no ID, don't pass that value to removeSessionIdListener or removeSessionIdentifiedListener. Use a flag instead (below).

If you need to stop listening early (for example, when a single-page-app component unmounts), use a flag in your callback instead of relying on the listener ID:

let active = true

warmly('addSessionIdentifiedListener', function (payload) {
  if (!active) return
  // handle payload
})

// later, on unmount
active = false

Early calls run when the widget is ready, not when you make them. A mistake in one of them (a misspelled method name, or undefined passed to a remove method) throws at that point and stops the early calls queued after it. Double-check method names against the table above.

Controlling the Chat Panel

show

Opens the chat panel.

warmly('show')

Good for "Talk to us" buttons. Wire it to your own CTA instead of asking visitors to find the bubble:

document.getElementById('talk-to-us').addEventListener('click', function () {
  warmly('show')
})

hide

Closes the chat panel. The launcher bubble stays visible so the visitor can reopen chat. hide does not remove the widget from the page.

warmly('hide')

makeWidgetFullScreen

Switches the open chat panel to full screen. It's a toggle: call it again to return to normal size. Use it while the panel is open, for example right after show.

warmly('makeWidgetFullScreen')

Session ID Listeners

The Warmly session ID is the key that ties your own tools to Warmly data. It matches the Session ID in intent signal webhooks, so you can join a GA4, Mixpanel, Amplitude or Heap event to the Warmly visitor behind it.

addSessionIdListener(callback)

Runs your callback with the session ID as soon as it's available.

Behavior:

  • If the session ID already exists, your callback runs right away (on the next tick, not synchronously).

  • If it doesn't exist yet, your callback runs once when it's created.

  • After it fires, the listener is removed automatically.

  • You can register as many listeners as you like. All of them fire.

warmly('addSessionIdListener', function (sessionId) {
  // Send to your analytics platform
  window.dataLayer = window.dataLayer || []
  window.dataLayer.push({ event: 'warmly_session', warmlySessionId: sessionId })
})

Don't re-register inside the callback. The session ID already exists at that point, so a new listener fires immediately and loops.

Sessions and inactivity. A session can end after a period of inactivity (around 16 minutes). When the visitor comes back, Warmly starts a new session with a new session ID. Don't cache the session ID: register your listener on every page load and use the ID it gives you there.

removeSessionIdListener(listenerId)

Cancels a listener that's waiting for the session ID to be created. If the session ID already exists when you register, your callback runs on the very next tick. To control that case, use the flag pattern from "Where to Put Your Code".

If the listener already fired, or the ID is unknown, the call has no effect and logs a warning.

const listenerId = warmly('addSessionIdListener', function (sessionId) {
  console.log('Warmly session:', sessionId)
})

// later, if you no longer need it
warmly('removeSessionIdListener', listenerId)

Identified Visitor Listener

Enabled on request. addSessionIdentifiedListener is turned off by default. Ask your CSM or email [email protected] to enable it for your workspace. Until it's on, the method can be called safely but never fires.

addSessionIdentifiedListener(callback)

Runs your callback the moment Warmly identifies the visitor, and again whenever that identification changes. For example, the company first, then the person.

Behavior:

  • Fires again whenever the identification changes: a new email, domain, identification type, score or confidence. Exact repeats are skipped.

  • It never drops from a person (full) back to company only (partial).

  • The domain can change. An early company match from the visitor's network can be replaced by the person's own company once they're identified. Always use the latest payload.

  • The listener stays registered. It keeps firing until you remove it.

  • If the visitor was already identified when you register, your callback runs right away with the current identification.

  • Fires again on each page load for an identified visitor, so every page gets the data.

  • If your callback throws, the error is logged and the listener stays subscribed.

const listenerId = warmly('addSessionIdentifiedListener', function (payload) {
  if (payload.completeness === 'full') {
    analytics.identify(payload.email, { warmlySessionId: payload.sessionId })
  } else {
    analytics.group(payload.domain)
  }
})

Payload fields:

Field

Type

Description

sessionId

string

The Warmly session ID. Same value as addSessionIdListener and webhooks

email

string or null

Identified person's email. Null when only the company is known

domain

string or null

Identified company's domain

completeness

partial or full

full when a person (email) is identified, partial when only the company is

identificationConfidence

string or null

Very_High, High, Moderate, Low or None

identificationScore

number or null

0 to 1. Easier to filter on than confidence, e.g. score > 0.6

identificationType

string or null

How the visitor was identified, e.g. form_fill, inbound_chat_inquiry, previous_session, hubspotutk, warmly_company_api

The payload covers identification only. Company details (name, industry, size) and contact details (title, LinkedIn) aren't included. Join on sessionId against webhooks or the REST API to get them.

removeSessionIdentifiedListener(listenerId)

Stops an identified listener. Safe to call before the callback has ever fired.

warmly('removeSessionIdentifiedListener', listenerId)

What's Not Part of the API

These come up often. They exist, but they aren't supported, and they can change without notice:

  • localStorage and the warmly_fingerprint global. Internal to the widget. Use the listeners above instead.

  • The warmly_<clientId> cookie. Set on Warmly's domain as HttpOnly, so browser JavaScript can't read it anyway.

  • Event listeners for chat activity (message sent, chat opened or closed). Not available today.

  • A destroy or disable method. There isn't one. To keep chat off specific pages and stop recording page views there, ask your CSM or [email protected] to add them to your workspace's tracking exclusions.

Troubleshooting

  • warmly is not defined. Your code ran before the Warmly script did, or the script isn't on the page. The Warmly script is deferred, so inline scripts run before it even when placed after it. Move your calls into a DOMContentLoaded handler (see "Where to Put Your Code"), and check that the Warmly script is in your site's <head> (copy it from Settings).

  • Method <name> is not supported. Typo, or a method that isn't in the table above. Method names are case-sensitive.

  • The listener ID is undefined. You called the method before the widget finished loading. The callback still works. Use the flag pattern to stop it. See "Where to Put Your Code" above.

  • warmly('show') doesn't open the chat. Call it from a visitor action, such as a button click, once the widget is on the page. See "Where to Put Your Code" above.

  • addSessionIdentifiedListener never fires. Either it isn't enabled for your workspace yet (contact support), or Warmly hasn't identified this visitor. Not every visitor gets identified. To test, fill out a form or start a chat and share your work email.

  • addSessionIdListener fired once and never again. Expected. It's a one-time listener. See "Sessions and inactivity" above.

  • Events logged after a long idle don't match an active Warmly session. If the page sat idle for a while, the session may have ended. Events tagged with its ID after that point won't belong to an active session. A later page load picks up the current session.

Have questions or feedback? Reach out to your CSM or email us at [email protected]