SDK surfaces
Public browser entrypoints for the Customer Agent SDK.
Surfaces
The SDK has three public surfaces. They point at the same browser singleton, so the choice is about how host code reaches the API: script global, package import, or React hooks.
| Surface | Entry | Purpose |
|---|---|---|
| Script SDK | window.CustomerAgent | Browser global command function. |
| ESM SDK | @customer-agent/sdk | Browser SDK package entry. |
| React hooks | @customer-agent/sdk/react | React access to SDK state, methods, and events. |
Public Exports
| Export | Type | Purpose |
|---|---|---|
default / CustomerAgent | CustomerAgentGlobal | Command function and method namespace. |
boot | (options: CustomerAgentOptions) => CustomerAgentWidget | Initializes the Messenger singleton. |
update | (options: Partial<CustomerAgentOptions>) => void | Applies public option updates. |
show / hide / toggle | (target?: CustomerAgentTarget) => void for show/toggle; () => void for hide | Controls Messenger visibility. |
openEntry | (entryId: string) => void | Opens a conversation entry id. |
shutdown | () => void | Removes the Messenger singleton. |
identify | (user: WidgetUser) => void | Updates visitor identity. |
setContext | (context: WidgetContextJson, options?: SetContextOptions) => void | Updates user context. |
on | (eventName, handler) => () => void | Subscribes to SDK events. |
getState | () => CustomerAgentState | null | Reads singleton state. |
getSession | () => Promise<{ conversationId: string } | null> | Ensures the support session. |
getSupportState | () => CustomerAgentSupportState | null | Reads support session state. |
getInterviewState | () => CustomerAgentInterviewState | null | Reads interview state. |
getInterviewSession | () => CustomerAgentInterviewSession | null | Reads active interview session data. |
ensureInvitation | () => Promise<{ invitationId: string } | null> | Creates or returns an interview invitation id. |
startInvitation | (invitationId: string) => Promise<{ entryId: string; sessionId: string } | null> | Starts an interview session. |
chooseInvitation | (invitationId: string, choice: "close" | "later") => Promise<void> | Records an invitation choice. |
sendInterviewMessage | (content: string) => Promise<void> | Sends an active interview message. |
loadInterviewReward | (sessionId?: string) => Promise<unknown> | Loads interview reward data. |
CUSTOMER_AGENT_EVENTS | constant | Stable event names. |
SDK imports have no server-side side effects. SDK control methods are browser behavior.