Developers

Events & widget states

React to what the widget is doing — state transitions, live team availability, and the full state list.

Events

GlimpzeWidget.events holds the canonical event names. Subscribe with GlimpzeWidget.on(...), or listen on window; both deliver the same (sanitized) detail.

EventConstantFires whenDetail
State changeevents.STATE_CHANGE (glimpze:state-change)The widget transitions state{ state, previousState, event }
Availabilityevents.AVAILABILITY_CHANGE (glimpze:availability-change)Live: an agent goes online/offline or a call starts/ends (pushed in real time, de-duped to genuine changes), plus once shortly after boot{ isAvailable, agents: { online, free, busy }, nextAvailableAt }
Readyevents.READY (glimpze:ready)Once, the moment window.GlimpzeWidget is the live API and every call queued before boot has been replayed. A late listener misses it Use await GlimpzeWidget.ready() if you may subscribe late.{ version }
Internalevents.INTERNAL_EVENT (glimpze:event)Advanced internal bus events{ type, payload }
// Via the API (recommended):
GlimpzeWidget.on(GlimpzeWidget.events.STATE_CHANGE, ({ state, previousState }) => {
  console.log('moved from', previousState.value, 'to', state.value);
});

// Or on window, without touching the API object:
window.addEventListener(GlimpzeWidget.events.AVAILABILITY_CHANGE, (evt) => {
  toggleBanner(evt.detail.isAvailable);
});

CTA template events

Two internal-bus event types cover embedded CTA templates, so you can send impressions and clicks to your own analytics.

TypeFires whenPayload
cta_template_shownAn instance first scrolls into view, once per instance per page load{ templateId, surface: 'embed' }
cta_template_clickedA button inside a template is clicked{ templateId, surface: 'embed', action }
GlimpzeWidget.on(GlimpzeWidget.events.INTERNAL_EVENT, ({ type, payload }) => {
  if (type === 'cta_template_shown')   analytics.track('Glimpze CTA seen',    payload);
  if (type === 'cta_template_clicked') analytics.track('Glimpze CTA clicked', payload);
});
Capability tokens are never exposed. Conversation secrets and room URLs are stripped from every public surface, events and getStatus(). Internal identifiers used by the runtime are not part of the public contract and may change.

Widget states

getStatus().state and the STATE_CHANGE event report one of:

StateMeaning
idleClosed / inactive.
checkingSessionRestoring an existing session on load.
preInteractionChoiceThe home screen (call / chat choice).
inChatOnlyA text conversation is active.
incomingCallFromChatAn agent is calling the visitor.
creatingCallSetting up a call.
connectingWaiting for an agent to accept.
queuedWaiting in queue for an available agent.
joiningJoining the call room.
inCallActive call in progress.
reconnectingAttempting to reconnect a dropped call.
reconnectFailedReconnection gave up.
unavailableNo agents available (and AI not handling).
errorAn error occurred.

States are an evolving contract: branch on the ones you need and tolerate unknown values rather than assuming the full set.