stradaChat object that you must add to your site to use any Web SDK functionality, along with corresponding settings and actions.
Settings
Configure the Web SDK by creating astradaSettings object in the global window scope.
stradaChat.start method. (See Delay widget loading.)
The Web SDK requires that
window.stradaSettings be defined before the script loads. You must therefore
define window.stradaSettings before the script, or use the lazy option and call start() manually.organizationId
organizationId: string; (required)
Your Strada organization ID. You can find this in the Strada dashboard.
agentId
agentId: string; (required)
The ID of the agent to load in the chat widget. You can find this in the Strada dashboard.
agentVariables
agentVariables?: Record<string, unknown>;
Pass data that you want to make available to your agent through agentVariables. This data can be accessible to the AI agent or be used in your actions.
metadata
metadata?: Record<string, unknown>;
Use metadata to pass information about a user to Strada for attribution and analytics purposes. This data is not accessible to the AI agent during conversations. For passing data that should be available in chat conversations, use agentVariables instead.
Meta field keys should not include whitespace, emojis, or special characters.
secureMetadata
secureMetadata?: Record<string, unknown>;
Use secureMetadata to pass sensitive data that requires an extra layer of protection. The values of secure metadata are never revealed in the UI, but they are still accessible through actions.
Use secure metadata for sensitive identifiers, tokens, or confidential information that your actions need
but should not be visible in the dashboard.
stradaReadyCallback
stradaReadyCallback?(params: { isLoaded: boolean }): void;
Callback invoked when the SDK completes initialization. Useful for asynchronous widget loading scenarios.
toggleCallback
toggleCallback?(isOpen: boolean): void;
Callback triggered whenever the widget opens or closes.
lazy
lazy?: boolean;
When set to true, this will prevent the widget from loading until the stradaChat.start(...) method is called. (See Delay widget loading.)
hideButton
hideButton?: boolean;
Hides the default floating button when set to true, allowing you to trigger the widget through custom UI elements.
widgetUrl
widgetUrl?: string;
Specifies a custom widget URL. Unless directed by a Strada team member, you should not change this value.
getUserToken
getUserToken?(): Promise<string | null>;
Function that retrieves a JWT token from your backend for user authentication. Returns a token to establish a verified user identity for the chat session.
The
getUserToken function should return a Promise that resolves to a JWT token string, or null if
authentication should be skipped.Actions
All actions are called through the globalstradaChat object.
start
start(settings: StradaSettings): Promise<void>;
Initializes the SDK. Automatically called on load unless lazy mode is enabled, in which case you must call this method manually.
open
open(options?: { agentId?: string }): Promise<void>;
Opens the widget. Pass an agentId to switch agents when opening.
close
close(): Promise<void>;
Closes the chat widget.
setMetadata
setMetadata(data: Record<string, unknown>): Promise<void>;
Updates metadata after initialization. Primarily useful in Single Page Applications where user context changes while the widget remains active.
Meta field keys should not include whitespace, emojis, or special characters.
subscribeEvent
subscribeEvent(eventKey: string, callback: (data: object, context: object) => void): Promise<number>
Registers a callback for SDK events. Returns a subscription ID for later removal.
stradaReadyCallback to ensure the SDK is loaded and no events are missed:
| Event key | Data | Description |
|---|---|---|
strada:ready | { isLoaded: boolean } | Triggered when the widget has finished loading and is ready to use. |
unsubscribeEvent
unsubscribeEvent(subscriptionId: number): void;
Removes an event subscription using its subscription ID.