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 }
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);
});
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.