Hierarchy

  • ChatSdk

Constructors

Properties

#contactCustomFieldsQueue: CustomFieldsMap = ...
#customer: Customer
#customerId: undefined | CustomerIdentityIdOnExternalPlatform
#customerImage: undefined | string
#customerName: undefined | string
#incomingChatEventMiddleware: ChatEventMiddleware = ...
#isAuthorizationEnabled: undefined | boolean
#isThirdPartyCookiesSupported: undefined | boolean
#messageEmitter: IChatEventTarget = ...
#ready: PromiseWithResolvers<void> = ...

The current connection attempt's authorization outcome: #createSocketUrl() rejects it on a failed grant and #finishConnect() resolves it on success. connect() / retryAuthorization() / resetSession() each install a fresh one before starting a new attempt, since a settled promise can't be re-settled for the next attempt.

#streamedMessageHandler: StreamedMessageHandler = ...
#websocketClient: null | WebSocketClient = null
channelId: ChannelId = ''
isLivechat: undefined | boolean
onAuthorization?: AuthorizationCallback
onError?: ErrorCallback
onRawEvent?: RawEventCallback

Methods

  • Returns Promise<void>

  • Returns Promise<string>

  • The tail shared by connect() and retryAuthorization() once #createConnection() has run: wait for the grant to settle (for secure sessions), wire up the Customer, and mark the instance ready. Extracted because retryAuthorization() needs to run exactly this same sequence after its own #createConnection() call — duplicating it would drift the two entry points apart (e.g. one getting the Customer wiring and the other not).

    Returns Promise<boolean>

  • Setup Environment endpoints

    Parameters

    Returns void

  • Parameters

    • error: unknown

    Returns void

  • Returns Promise<void>

    Deprecated

    • do not use
  • Send Authorization Event

    Parameters

    • Optional credentials: string | ThirdPartyCredentials

      an authorization code (shorthand for the authorization_code grant), or a ThirdPartyCredentials object to use the implicit grant or supply a PKCE code verifier

    • Optional visitorId: VisitorId

      visitor id

    • Optional browserFingerprint: BrowserFingerprint

      BrowserFingerprint object, use getBrowserFingerprint helper function to create it

    Returns Promise<ConsumerAuthorizationSuccessPayloadData | CustomerReconnectSuccessPayloadData>

    Deprecated

    • use Secured Session flow instead (SDK option securedSession and connect)

    Throws

    AuthorizationError

    • This exception is thrown when the authorization or refresh token fails

    Throws

    ChatSDKError - if credentials is an object whose grantType is missing or is not 'authorization_code' | 'implicit'. Rejects the promise; not delivered via onError.

  • Initiate a WebSocket connection

    Parameters

    • Optional credentials: string | ThirdPartyCredentials

      an authorization code (shorthand for the authorization_code grant), or a ThirdPartyCredentials object to use the implicit grant or supply a PKCE code verifier

    • Optional botProtection: BotProtection

      bot protection token (e.g. reCAPTCHA, Turnstile) sent with the initial authorization_code grant

    Returns Promise<boolean>

    Promise - true if the connection was created, false if the connection already exists. Credentials are stored before that check, so passing them to an already-connected instance seeds them for the next grant run by retryAuthorization() or resetSession().

    Throws

    ChatSDKError - if credentials is an object whose grantType is missing or is not 'authorization_code' | 'implicit'. Rejects the promise; not delivered via onError.

    Throws

    ChatSDKError | IpAddressBlockedError | CaptchaRequiredError - for secure sessions, if the authorization grant is rejected. The error is also delivered via onError; call retryAuthorization() to recover from a CaptchaRequiredError.

  • Generate Authorization Token from the given url

    Parameters

    Returns Promise<AuthorizationToken>

    Deprecated

    the additional message content is handled internally, there is no need to use this method

  • Get channel info Returns channel info like feature toggle status, translations, file upload restrictions, theme color settings etc.

    Returns Promise<ChannelInfo>

    ChannelInfo

    Throws

    ChatSDKError

  • Get list of available threads

    Returns Promise<null | ThreadView[]>

    list of threads

  • Returns Promise<void>

  • Reset the ChatSdk session and clear it from customer data

    • it disconnects the WS connection and creates a new one
    • generates new IDs if not provided

    Parameters

    Returns Promise<void>

  • Recover from a rejected authorization grant (e.g. after the SDK surfaced a CaptchaRequiredError via onError) by re-running the grant with a fresh bot-protection token.

    A plain connect() retry cannot recover here: #createConnection() leaves #websocketClient non-null on failure, so connect() would just return false. This tears the failed attempt down and re-runs it with a fresh #ready deferred.

    Parameters

    • botProtection: BotProtection

      fresh bot protection token (e.g. reCAPTCHA, Turnstile) for the retried authorization_code grant

    Returns Promise<boolean>

    Promise - true once the retried connection succeeds

    Throws

    ChatSDKError | IpAddressBlockedError | CaptchaRequiredError - if the retried grant is rejected again (e.g. the captcha challenge was failed twice); safe to call again with a new token

  • Send the Offline Message

    Parameters

    Returns Promise<MessageSuccessEventData>

    success

    Throws

    SendMessageFailedError

    • This exception is thrown when a message fails to send. The error contains (error.data) a response from the backend with details.

Generated using TypeDoc