Basic Embedding
Add the script tag to your HTML file, typically just before the closing</body> tag:
The
defer attribute ensures the script loads asynchronously without blocking page rendering.Complete Example
Here’s a full example with all available configuration options:Getting the Widget Bundle
The widget JavaScript bundle is served from your backend deployment:Development
Production
Widget Initialization
The widget automatically initializes when the DOM is ready. It reads all configuration from thedata-* attributes on the script tag.
- Root element ID:
os-chat-widget-root - Z-index:
999999(ensures it appears above most content) - Position: Fixed at bottom-left or bottom-right corner
Required Attributes
Only two attributes are required for the widget to work:The URL of your backend chat API endpoint. Example:
http://localhost:4000/chatYour widget API key for authentication. This should match the
WIDGET_API_KEY environment variable in your backend.If either
data-api-url or data-api-key is missing, the widget will log an error to the console and not initialize:Multiple Widgets
The widget checks for existing instances and won’t initialize twice on the same page:Next Steps
Configuration
Customize the widget with data attributes
Customization
Style the widget to match your brand