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.
open() (see open action).
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.
parentElement
parentElement?: string;
CSS selector for a custom DOM element to mount the widget into (e.g. '#my-container' or '.widget-container'). If not provided, the widget mounts to document.body with fixed positioning (floating on desktop, full-screen on mobile).
Use this when you want the chat embedded in a specific part of your layout (e.g. a sidebar or dedicated panel) instead of the default bottom-right overlay. The widget will fill the parent element. Typically used together with hideButton: true and your own trigger (e.g. a tab or button) that calls stradaChat.open().
Requirements:
- The target element must exist in the DOM when the SDK initializes.
- The container should have
position: relativeandpadding: 0,margin: 0so the widget can fill it correctly. - Use a string selector only (e.g.
'#id','.class'). HTMLElement references are not supported.
document.body and logs a console warning.
Single Page Applications: The widget mounts once on initial page load. If your application uses
client-side routing (React Router, Vue Router, etc.), keep the widget in a layout container that persists
across route changes. The
parentElement cannot be changed dynamically after the widget initializes.darkMode
darkMode?: boolean;
Enables dark mode theme for the widget. Defaults to false.
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; agentVariables?: Record<string, unknown>; metadata?: Record<string, unknown>; secureMetadata?: Record<string, unknown> }): Promise<void>;
Opens the widget. You can optionally pass context to switch agents or update variables.
Field-Level REPLACE Semantics:
- Each field you provide REPLACES that entire field (no merging)
- Fields you omit keep their current value
- Pass
{}to clear a field
REPLACE Semantics: Providing
agentVariables: { page: 'checkout' } REPLACES all variables with just { page: 'checkout' }. To keep existing variables, include them explicitly or omit the field entirely.Changing
agentVariables creates a new chat context. Each unique combination of agentId +
agentVariables represents a different conversation.close
close(): Promise<void>;
Closes the chat widget.
Context-Based Chat System
The widget maintains separate chats for each unique context. Context is determined by the combination oforganizationId, agentId, and agentVariables.
How it works
- Each unique context creates or accesses a separate chat
- Changing variables creates a new context = different chat
- Same variables returns to the same chat (history preserved)
Updating variables dynamically
To update variables after initialization, pass them toopen().
setDarkMode
setDarkMode(enabled: boolean): void;
Toggles dark mode dynamically. Useful for syncing the widget theme with your application’s theme.
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.