Events
GlimpzeWidget.events holds the canonical event names. Subscribe with GlimpzeWidget.on(...), or listen on window — both deliver the same (sanitized) detail.
| Event | Constant | Fires when | Detail |
|---|---|---|---|
| State change | events.STATE_CHANGE (glimpze:state-change) | The widget transitions state | { state, previousState, event } |
| Availability | events.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 } |
| Internal | events.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:
| State | Meaning |
|---|---|
idle | Closed / inactive. |
checkingSession | Restoring an existing session on load. |
preInteractionChoice | The home screen (call / chat choice). |
inChatOnly | A text conversation is active. |
incomingCallFromChat | An agent is calling the visitor. |
creatingCall | Setting up a call. |
connecting | Waiting for an agent to accept. |
queued | Waiting in queue for an available agent. |
joining | Joining the call room. |
inCall | Active call in progress. |
reconnecting | Attempting to reconnect a dropped call. |
reconnectFailed | Reconnection gave up. |
unavailable | No agents available (and AI not handling). |
error | An error occurred. |
States are an evolving contract — branch on the ones you need and tolerate unknown values rather than assuming the full set.