API reference
Loader (window.Dialogue)
The imperative API for non-React pages. window.Dialogue is the only global the SDK installs; the heavy React tree is lazy-loaded on the first open().
Install
html
<script async src="https://sdk.dialogue.ai/v1/dialogue.js"></script>Or, with a bundler: await import('@dialogueai/loader'). Either way window.Dialogue is installed. See the vanilla guide for the full walkthrough.
Methods
ts
Dialogue('init', config) // configure once (idempotent for same config)
Dialogue('open', { studyId }) // mount + open the study
Dialogue('close') // unmount the widget (alias of destroy, spec §8)
Dialogue('update', { appearance }) // re-theme live; immutable keys ignored
Dialogue('on', event, callback) // subscribe
Dialogue('off', event, callback) // unsubscribe
Dialogue('preflight', (result) => {}) // capability check
Dialogue('debug', true) // toggle verbose logging
Dialogue('version', (v) => {}) // SDK version string
Dialogue('destroy') // unmount + tear downon/off called before open() are buffered and wired up once the widget mounts.close() fully unmounts and runs the core’s dispose() — per spec §8 it is equivalent to destroy(), so it does not keep a hidden instance.update() mutates only the mutable keys: appearance re-themes live, and locale applies only before the interview locks it at creation. publishableKey and bootstrapTokenProvider are immutable.init() config
publishableKeystringoptional
Your public key (
pk_…). Optional in degraded anonymous mode.bootstrapTokenProvider() => Promise<BootstrapTokenResult>optional
Same contract as the React provider. See Authentication.
containerstring | HTMLElementoptional
Where to mount: a CSS selector or an element. Defaults to a generated container.
localeDialogueLocaleoptional
Initial UI locale.
appearanceAppearanceoptional
Theming for the styled drop-in — same object as the React appearance prop. Mutable at runtime via
Dialogue('update', { appearance }).environment'production' | 'staging'default: 'production'optional
Backend environment.
baseUrlstringoptional
Override the API base URL (e.g. a same-origin proxy).
debugbooleanoptional
Verbose logging.
publishableKey and bootstrapTokenProvider are immutable for an instance. Calling init again with a different value emits a config.publishable-key-and-init-mismatch error.Globals
The loader touches exactly three globals, nothing else:
window.Dialogue— the function you call.window.Dialogue.q— the pre-load call queue.window.__dialogueLoaded— a sentinel marking the stub as installed.