window.AdoptAI
) or the NPM package (import { ... } from '@adoptai/sdk
), the method signatures remain consistent.
Global Object
When using the Script/CDN approach, all SDK methods are available via:Method Reference
init(licenseKey: string, opts?: InitConfig): Promise<void>
Initializes the SDK (required for NPM installs only).
boot(userId: string, userProperties?: object, instanceAttributes?: object): Promise<void>
Starts the Copilot for a specific user session.
shutdown(): void
Hides the Copilot UI. Typically called on logout or user switch.
setUserProperties({ userProperties: object }): void
Updates user-specific properties after boot.
addRouter(callback: (url: string) => void): void
Registers your app’s router so Adopt can track and respond to route changes in SPAs.
setCopilotHeaders(headers: Record<string, string>): void
Dynamically updates API headers—useful for refreshing tokens mid-session.
Error Handling
All async methods return Promises. Usetry/catch
blocks to gracefully handle issues during init or boot: