Skip to main content

CDN Installation Guide

The Moss SDK supports CDN installation for applications that donโ€™t use React or prefer a simple script tag approach. This method automatically configures the SDK using your application settings from the Moss Dashboard.

Prerequisites

  • A registered application in the Moss Dashboard
  • Your Application ID (UUID format)
  • A website where you want to install the SDK

๐Ÿš€ Quick Start

Basic Installation

The simplest way to get started is with a single script tag:

Installation with User ID

For logged-in users, include the userId directly in the script URL:

All-in-One Installation

The SDK will:
  • โœ… Automatically fetch configuration from your dashboard
  • โœ… Use the provided user ID or generate anonymous one
  • โœ… Display the floating assistant button
  • โœ… Handle all initialization automatically

๐Ÿ“‹ Getting Your Application ID

  1. Sign up at Moss Dashboard
  2. Create a new application or select an existing one
  3. Copy the Application ID from your application settings
  4. Configure SDK settings in the dashboard (optional)
Application ID in Dashboard

โš™๏ธ Configuration Options

Method 1: Pre-load Configuration

Set window.mossSettings before the SDK loads to customize behavior:

Method 2: Page Sanitization

Configure how the SDK captures page content for better context accuracy by passing a sanitization function:

Method 3: Custom API Base URL

If youโ€™re using a custom backend deployment:

๐ŸŽฎ Global API

Once loaded, the SDK exposes a global MossSDK object for runtime control:

User Identification

Runtime Configuration

Lifecycle Management

๐Ÿ“ฑ Single Page App Integration

For SPAs, update the SDK when routes or user state changes:

๐Ÿ”’ Security & Domain Restrictions

Configure allowed domains in your dashboard to restrict where the SDK can be loaded: Domain Restrictions in Dashboard The SDK will automatically check the requesting domain and block unauthorized usage.

๐Ÿ†š CDN vs NPM Installation

๐Ÿšจ Troubleshooting

SDK Not Loading

  1. Check Network: Look for failed requests in DevTools Network tab
  2. Verify Application ID: Ensure it matches your dashboard exactly
  3. Check Domain: Make sure your domain is whitelisted (if configured)
  4. Console Errors: Look for JavaScript errors in the browser console

Configuration Not Applied

  1. Timing: Ensure window.mossSettings is set before the script tag
  2. Validation: Check console for configuration validation errors
  3. Debug Mode: Enable debug mode to see detailed logs:

User Identification Issues

  1. Call After Load: Make sure to call identify() after SDK initialization
  2. Check Storage: User IDs are stored in localStorage for persistence
  3. Verify Format: Ensure user data follows the expected format

๐Ÿ”ง Advanced Configuration

Custom Configuration Fields

You can pass any custom data through the configuration object:
This data will be available to the AI assistant for providing contextual help.

Error Handling

๐Ÿ“Š Analytics & Monitoring

The SDK automatically tracks:
  • Initialization success/failure
  • User identification events
  • Configuration updates
  • Session management
  • Error occurrences
Access these metrics through your Moss Dashboard analytics section.

๐Ÿ”— Next Steps

  1. Test Installation: Use the browser console to verify window.MossSDK exists
  2. Customize Settings: Configure your application in the Moss Dashboard
  3. Test User Flows: Try the identify() and updateConfig() methods
  4. Monitor Usage: Check analytics in your dashboard
  5. Advanced Features: Explore the full SDK Reference