Customer Agent

Messenger methods

UI controls and state on a mounted CustomerAgentWidget.

mountWidget(options) from @customer-agent/sdk/widget attaches the Messenger and returns Promise<CustomerAgentWidget>. A supplied client is required. Session and message actions belong to that client; see Headless client.

Methods

MethodArgumentsReturnsEffect
getStateNoneCustomerAgentWidgetStateReads this mount's cached UI snapshot.
subscribelistener: () => void() => voidObserves UI snapshot changes; returns an unsubscribe function.
onEvent name, handler() => voidObserves widget events and business events forwarded from its client.
showOptional CustomerAgentTargetvoidOpens the panel and selects a target when supplied.
hideNonevoidCloses the panel.
toggleOptional CustomerAgentTargetvoidToggles the panel, updating the target when supplied.
updatePartial presentation optionsvoidUpdates this mount's appearance and launcher.
unmountNonevoidRemoves this instance and its listeners, restoring host attributes and scroll state.

UI controls reject use after unmount by throwing an error. unmount() is idempotent; calling it again cannot remove a later Messenger. The client keeps running. getState() remains readable with isReady: false, isOpen: false, and a cleared launcher anchor after unmount.

The mounting promise confirms attachment. Shell readiness is published separately in UI state and widget.ready; a ready handler registered after readiness receives one asynchronous replay. The conversation panel is lazy, and widget readiness does not mean a support session has started.

UI State

FieldTypeMeaning
appId, widgetIdstringIdentifiers from the supplied client.
isOpenbooleanPanel visibility.
isReadybooleanThe minimal Messenger shell is ready.
activeTargetOptional CustomerAgentTargetCurrent one-shot opening target.
activeEntryIdOptional stringCurrent conversation route entry.
launcher.targetConfiguredbooleanA custom target was configured.
launcher.targetConnectedbooleanThe custom target is currently resolved.
launcher.anchorHTMLElement | nullThe connected custom target or SDK-created launcher host.

Business state is available from client.getState(), not copied into the widget snapshot. Closing the panel clears its one-shot target and retains navigation memory for a later trigger reopen. openOnInit opens during mounting without emitting widget.opened.

Updates

update accepts presentation fields from Messenger options. A different client or mount requires a new mounting call. openOnInit applies only at mount time. Updating launcher replaces that object: include its target when retaining a custom target while changing placement or offset. header, theme, and other nested presentation objects are replaced rather than deeply merged.

A non-embedded mobile fullscreen Messenger locks host scrolling while open. It restores scrolling when hidden, unmounted, or changed to bottom-sheet presentation. Embedded Messengers do not lock the host document.

Targets

See Support and interview sessions for supported targets. Calling a client business action does not implicitly open the Messenger; use its widget handle to select and show the resulting conversation.

show({ type: "support", scene: "retention" }) opens the loading panel while its client creates or restores the requested scene. On creation failure, the panel selects ordinary support. The method returns void; request status is observable through the client's scene state. Hiding, unmounting or selecting another target prevents a late failure from overriding that navigation.

On this page