Skip to main content
DocumentationWeb widget
Version 0.3.1Modern browsers with JavaScript enabled

Web widget SDK: API reference

Web widget: Typed browser APIs for the DobroDesk loader, widget lifecycle, appearance, events and host actions.

On this page

Configuration

integrationId

Required

The public integration identifier copied from the DobroDesk widget channel.

integrationId
string

launcher

Default: default

Native navigation and web launcher or panel presentation options.

launcher
"default" | "hidden" = "default"

locale

Default: auto

The widget locale used for content. Web defaults to auto; native widget bundles currently support en, uk, de and es.

locale
string? = "auto"

loaderUrl

Default: https://widget.dobrodesk.com/widget/loader/v1.min.js

The versioned browser loader script URL. Leave it unset to use the DobroDesk hosted loader.

loaderUrl
string?

appearance

The shared appearance-v2 object: colors, typography, layout and shadow within documented bounds.

appearance
DobroDeskWidgetAppearance?

appearanceElement

The shared appearance-v2 object: colors, typography, layout and shadow within documented bounds.

appearanceElement
HTMLElement?

container

Native navigation and web launcher or panel presentation options.

container
HTMLElement?

identityToken

A host backend function that returns a short-lived signed customer JWT. Keep its signing secret out of the app.

identityToken
string?

helpCenterHandoffToken

Updates a short-lived signed identity or Help Center handoff token.

helpCenterHandoffToken
string?

openOnReady

Default: false

Native navigation and web launcher or panel presentation options.

openOnReady
boolean?

previewContext

Bounded JSON context supplied to explicitly registered host actions.

previewContext
DobroDeskWidgetPreviewContext?

prefill

Bounded JSON context supplied to explicitly registered host actions.

prefill
DobroDeskWidgetPrefill?

context

Bounded JSON context supplied to explicitly registered host actions.

context
DobroDeskWidgetContext?

hostActions

Allowlisted application callbacks for guided widget actions. They do not authenticate network requests.

hostActions
Record<string, DobroDeskWidgetHostActionHandler>?

Lifecycle and conversation

createDobroDeskWidget

Creates the client and validates the integration configuration.

createDobroDeskWidget
createDobroDeskWidget(options: DobroDeskWidgetOptions) -> DobroDeskWidgetClient

Parameters

options.integrationIdstringRequired
The public integration identifier copied from the DobroDesk widget channel.
options.loaderUrlstring?
The API origin is HTTPS in production. Native clients allow localhost HTTP for development.
options.openOnReadyboolean?
Native navigation and web launcher or panel presentation options.
Errors
  • widget_context_invalid
  • widget_mount_container_invalid
  • widget_appearance_invalid

ready

Resolves after the web loader and frame handshake complete.

ready
ready: Promise<void>

open / close / toggle

Opens the widget panel.

open / close / toggle
open(): void; close(): void; toggle(): void

hide / show

Hides the widget presentation.

hide / show
hide(): void; show(): void

logout

Ends the active customer session and disposes optional capability state.

logout
logout(): void

destroy

Destroys the page widget and releases the active instance.

destroy
destroy(): void

Widget presentation

setLauncherVisibility

Shows or hides the built-in launcher without closing the widget.

setLauncherVisibility
setLauncherVisibility(visible: boolean): void

setLocale

Changes the widget locale.

setLocale
setLocale(locale: string): void

prefill

Sets customer fields before the conversation starts.

prefill
prefill(value: DobroDeskWidgetPrefill): void

setIdentityToken

Updates a short-lived signed identity or Help Center handoff token.

setIdentityToken
setIdentityToken(token: string): void

setHelpCenterHandoffToken

Updates a short-lived signed identity or Help Center handoff token.

setHelpCenterHandoffToken
setHelpCenterHandoffToken(token: string): void

setPreviewContext

Sets the memory-only operator preview context used by the web loader.

setPreviewContext
setPreviewContext(context: DobroDeskWidgetPreviewContext): void

openHelp / openArticle

Opens the widget Help view.

openHelp / openArticle
openHelp(): void; openArticle(articleId: string): void

requestHuman

Requests the configured human handoff.

requestHuman
requestHuman(): void

setContext / getContext

Replaces bounded host-action context.

setContext / getContext
setContext(value): void; getContext(): DobroDeskWidgetContext

Appearance and accessibility

updateAppearance

Applies a validated runtime appearance override.

updateAppearance
updateAppearance(appearance: DobroDeskWidgetAppearance): void
Errors
  • widget_appearance_invalid

resetAppearance

Resets runtime appearance to admin or supplied values.

resetAppearance
resetAppearance(appearance?: DobroDeskWidgetAppearance): void

refreshAppearance

Re-reads host CSS variables and applies bounded values.

refreshAppearance
refreshAppearance(hostElement?: HTMLElement): void

getAppearance

Returns effective appearance and field sources.

getAppearance
getAppearance(): DobroDeskWidgetAppearanceSnapshot | null

State, loading and events

getState

Returns the current widget state without subscribing.

getState
getState(): DobroDeskWidgetState

DobroDeskWidgetLoadingState

The shared loading state is one of idle, starting-session, loading-messages, sending-message, waiting-for-assistant, executing-action, reconnecting or flushing-outbox.

DobroDeskWidgetLoadingState
{ active: boolean; phase: idle | initializing | loading-content | loading-session | sending-message | waiting-for-response | executing-action | reconnecting | error; operationId?; kind?; scope?; requestId?; actionId?; startedAt?; errorCode? }

DobroDeskWidgetEventType

Native and wrapper events use the shared loading, session, snapshot, accepted-message, error and session-cleared envelope.

DobroDeskWidgetEventType
opened | closed | conversationStarted | messageSent | messageReceived | formSubmitted | handoffRequested | handoffStateChanged | unreadCountChanged | actionProposed | actionConfirmed | actionCompleted | actionFailed | hostActionRequested | stateChanged | loadingChanged

onStateChange

Notifies the host when widget state changes.

onStateChange
onStateChange(listener): () => void

onLoadingChange

Notifies the host about loading and reconnecting phases.

onLoadingChange
onLoadingChange(listener): () => void

on / off

Subscribes to a named widget event.

on / off
on(eventType, listener): () => void; off(eventType, listener): void

Errors

DobroDeskWidgetErrorCode

Handle stable machine-readable codes and keep server diagnostics out of customer UI.

DobroDeskWidgetErrorCode
widget_ready_timeout | widget_context_invalid | widget_mount_container_invalid | widget_appearance_invalid | host_action_failed | host_action_invalid_result | host_action_timeout | widget_logged_out | widget_identity_changed | widget_destroyed