Customer Agent

Support and interview sessions

Public support and interview state, targets, and session methods.

The client owns support and interview state and actions without UI. A mounted widget selects and shows conversation targets independently. Client business actions do not open a Messenger.

CustomerAgentTarget

show(target) and toggle(target) accept an optional target. The entry target selects a specific conversation entry by id.

type CustomerAgentTarget =
  | { type: "entry"; entryId: string }
  | { type: "home" }
  | { type: "interview"; campaignId?: string; sessionId?: string }
  | { type: "support"; scene?: CustomerAgentSupportScene }
TargetEffect
{ type: "support" }Opens the support conversation entry.
{ type: "support", scene: "retention" }Opens immediately while creating or restoring a separate signed-in support session. Creation failure switches the panel to ordinary support without sending a message.
{ type: "interview" }Opens the interview surface.
{ type: "interview", sessionId }Opens an interview session target.
{ type: "entry", entryId }Opens a specific conversation entry id.
{ type: "home" }Opens the panel home route.

Support State

type CustomerAgentSupportState =
  | { status: "idle" | "starting" | "refreshing" | "error"; error?: { message: string } }
  | { status: "ready"; conversationId: string }
MethodReturnsEffect
getSupportState()CustomerAgentSupportStateReads current support state.
getSession(options?)Promise<{ conversationId; messages }>Selects, restores or creates the requested support scene.

These methods are called on CustomerAgentClient. getSession() restores or creates a support session and returns its confirmed id and current messages. There is no uninitialized singleton return form.

type CustomerAgentSupportScene = "support" | "retention"
type GetSessionOptions = { scene?: CustomerAgentSupportScene }

SUPPORT_SCENE exports SUPPORT ("support") and RETENTION ("retention"). Omitting scene selects ordinary support. The "retention" scene requires a nonempty user.id and a server response confirming its flow binding. getSession rejects on failure and does not open a widget or switch to another scene on failure. Each scene retains its own messages. boot restores the cached ordinary support session. The "retention" scene is not restored from the browser cache and never reuses a cached id: getSession({ scene: "retention" }) resumes the user's open retention conversation or creates one, so a closed retention conversation is not reopened. sendMessage and uploadAttachment use the selected support scene; an in-flight send stays attached to its original conversation when the selection changes.

The widget lists ordinary support and an existing separate support scene as independent entries. Each scene retains its own composer draft and attachments. Changing identity clears both composers. Selecting a known support entry selects its sending target. Hiding or unmounting the widget leaves the client and its requests running. A late creation failure does not reopen a hidden panel or override a later selection.

Existing support sessions refresh every five seconds while the page is visible, including when the widget is closed. Browser focus or visibility restoration triggers an immediate refresh. Closed conversations stop polling when the server reports status: "closed". Card state changes do not determine whether a support conversation is closed.

Interview State

type CustomerAgentInterviewState =
  | { status: "idle" | "checking" | "unavailable" | "error"; error?: { message: string } }
  | {
      status: "available"
      campaignId: string
      title: string
      body: string
      startCta: string
      laterCta: string
    }
  | { status: "active"; entryId: `interview/session/${string}`; sessionId: string }
  | {
      status: "terminal"
      sessionId: string
      sessionStatus: "abandoned" | "aborted" | "completed" | "dismissed"
    }
StatusMeaning
idleNo active interview state.
checkingInterview availability is being read.
availableAn interview invitation is available.
activeAn interview session is active.
terminalThe interview session ended.
unavailableNo interview invitation is available.
errorThe interview request failed.

Interview Invitation Actions

The ESM entry exports stable invitation action values and their matching types.

declare const INTERVIEW_INVITATION_ACTION: Readonly<{
  CLOSE: "close"
  LATER: "later"
  START: "start"
}>

type CustomerAgentInterviewInvitationAction = "close" | "later" | "start"
type CustomerAgentInterviewInvitationChoice = "close" | "later"

chooseInvitation accepts CustomerAgentInterviewInvitationChoice, so its choice argument is limited to CLOSE and LATER. CustomerAgentInterviewInvitationAction also includes START.

Interview Methods

MethodReturnsEffect
getInterviewState()CustomerAgentInterviewStateReads current interview state.
getInterviewSession()CustomerAgentInterviewSession | nullReads the active interview session snapshot.
ensureInvitation()Promise<{ invitationId: string }>Creates or returns the current invitation id.
startInterview()Promise<{ entryId; sessionId; session }>Starts an eligible interview without opening UI.
startInvitation(invitationId)Promise<{ entryId; sessionId; session }>Starts an interview session from an invitation.
chooseInvitation(invitationId, choice)Promise<void>Records an invitation choice of "close" or "later".
sendInterviewMessage(content)Promise<void>Sends a message in the active interview session.
loadInterviewReward(sessionId?)Promise<unknown>Loads reward data for an interview session.

ensureInvitation() and startInterview() reject when no interview invitation is available. sendInterviewMessage() rejects when no interview session is active. loadInterviewReward() rejects when no session id is available.

CustomerAgentInterviewSession

type CustomerAgentInterviewSession = {
  sessionId: string
  status: "active" | "abandoned" | "aborted" | "completed" | "dismissed"
  messages: Array<{
    id: string
    role: "assistant" | "user"
    content: string
    createdAt: string
  }>
}

On this page