Customer Agent

ESM entry

Named instance factories, React bindings, and package exports.

The SDK uses explicit client instances. The root entry provides conversation state and actions; /widget attaches the built-in Messenger to a client, and /react provides instance-scoped hooks.

Package Exports

Export pathValuesPurpose
@customer-agent/sdkcreateClient, message/invitation/event constants, CUSTOMER_AGENT_VERSIONConversation client without UI or React.
@customer-agent/sdk/widgetRoot values and mountWidgetAttach and control the built-in Messenger.
@customer-agent/sdk/reactRoot values, mountWidget, CustomerAgentProvider, client and widget hooksReact bindings for supplied instances.
@customer-agent/sdk/sdk.jsBrowser script assetRegisters the same factories on window.CustomerAgent.
@customer-agent/sdk/messages/*Locale JSON catalogsBuilt-in UI translations.

The ESM entries have named exports and no default export. Widget and React entries re-export the core factory, so an integration can import its factories from one entry. The root entry's runtime and TypeScript declarations work without DOM libraries. React is an optional peer dependency.

Client

import { createClient } from "@customer-agent/sdk"

const client = createClient({ appId: "your-app" })
await client.boot()

Client options, methods, state, and errors are defined in Headless client.

Messenger

import { createClient, mountWidget } from "@customer-agent/sdk/widget"

const client = createClient({ appId: "your-app" })
await client.boot()
const widget = await mountWidget({ client })
widget.show({ type: "support" })
widget.unmount()
client.shutdown()

mountWidget requires a client and returns a handle bound to that mount. Unmounting leaves the client running. A new mount replaces the document's previous Messenger; either client can continue without UI. An old handle never controls a later mount.

Mounting requires a browser document. Imports are safe on the server. The returned promise resolves when the instance is attached; shell readiness is observed through widget.getState().isReady or widget.ready. The full conversation panel remains lazy.

Type Exports

The root exports CustomerAgentClient, CustomerAgentClientOptions, CustomerAgentClientState, CustomerAgentConversationState, CustomerAgentMessage, CustomerAgentAttachment, CustomerAgentContext, CustomerAgentUser, CustomerAgentPageOptions, SetContextOptions, CustomerAgentSupportState, CustomerAgentInterviewState, CustomerAgentInterviewSession, CustomerAgentInterviewInvitationChoice, CustomerAgentInterviewInvitationAction, CustomerAgentEventMap, and CustomerAgentEventName.

Action-card exports include CARD_OPERATION_STATUS, CustomerAgentActionCard, CustomerAgentCardOperation, CustomerAgentCardActionResult, and CustomerAgentMessagePart.

Widget and React entries additionally export CustomerAgentWidget, CustomerAgentWidgetOptions, CustomerAgentWidgetState, and CustomerAgentTarget. The widget entry also exports CustomerAgentBrowserSDK, the script namespace type.

Version 0.9.0 Migration

Previous surfaceInstance API
Default CustomerAgent export and named singleton methodsNamed createClient; call business methods on its returned client.
CustomerAgent.boot(options)createClient(clientOptions), client.boot(), and mountWidget({ client, ...presentation }).
Widget business methodsCall the supplied client. Use the widget only for UI controls.
CustomerAgentOptionsCustomerAgentClientOptions for business configuration; CustomerAgentWidgetOptions for UI.
Implicit singleton hooks or useCustomerAgentClientStateCustomerAgentProvider with the supplied client, then useCustomerAgentState.
Script command function, queue, or data-attribute auto-bootThe named factories on window.CustomerAgent.

The removed APIs have no compatibility aliases. brand, theme, launcher, and other presentation options belong to the widget. Identity, context, locale, and page metadata belong to the client. Client readiness and widget readiness are separate snapshots. The previously accepted, inert theme.colorScheme and theme.radius fields are removed; theme.primaryColor remains supported.

Self-hosted Assets

Publish the complete dist output when self-hosting. The script and ESM entries require their companion JavaScript chunks and locale/emoji assets. Chunk filenames are build output, not public package imports.

On this page