ChatBox SDK - Basic Integration Beginner

The simplest way to get started with ChatBox SDK. Perfect for quick integration and testing.

â„šī¸ About This Example: This demonstrates the minimal setup required to integrate ChatBox SDK. The widget appears as a floating chat button in the bottom-right corner. Use the configuration panel below to test different settings, user contexts, and scenarios without writing any code.

đŸŽ¯ What You'll Learn

📝 Integration Steps

Follow these simple steps to integrate ChatBox SDK into any website:

Step 1: Add the SDK Script

<!-- Auto-detect environment -->
<script>
  const isLocalhost = window.location.hostname === 'localhost';
  const sdkUrl = isLocalhost
    ? 'http://localhost:3003/chatbox-sdk.js'
    : 'https://cdn.dialogkit.io/chatbox-sdk.min.js';
  document.write('<script src="' + sdkUrl + '"><\/script>');
</script>

Step 2: Initialize with Configuration

<script>
  window.ChatBoxConfig = {
    apiKey: 'your-api-key-here',
    theme: {
      primaryColor: '#007bff',
      secondaryColor: '#6c757d'
    },
    ui: {
      title: 'Customer Support',
      subtitle: 'We\'re online now'
    }
  };
</script>

Step 3: That's It! 🎉

The SDK will automatically initialize and display a chat button in your chosen position (default: bottom-right).

🎨 Try It Out

Use the configuration panel at the top to:

💡 Configuration Options

Required:

Optional:

🔍 What's Next?

Once you're comfortable with the basics, check out these examples:

📚 Full Configuration Example

const chatBox = new ChatBoxSDK({
  // Required
  apiKey: 'your-api-key',

  // User Identification (optional)
  userId: 'user-12345',
  userMetadata: {
    name: 'John Doe',
    email: 'john@example.com',
    customFields: {
      plan: 'pro',
      signupDate: '2024-01-01'
    }
  },

  // Context (optional)
  context: {
    page: 'checkout',
    cartTotal: 99.99
  },

  // Theme (optional)
  theme: {
    primaryColor: '#007bff',
    secondaryColor: '#6c757d',
    backgroundColor: '#ffffff',
    textColor: '#333333',
    darkMode: false
  },

  // UI Text (optional)
  ui: {
    title: 'Customer Support',
    subtitle: 'We\'re online now',
    placeholder: 'Type your message...'
  },

  // Layout (optional)
  layout: {
    type: 'popup',          // or 'embedded'
    position: 'bottom-right' // or 'bottom-left', 'top-right', 'top-left'
  },

  // Behavior (optional)
  behavior: {
    autoOpen: false,
    rememberState: true,
    showUnreadCount: true
  }
});

// Event Listeners
chatBox.on('ready', () => console.log('Widget ready'));
chatBox.on('open', () => console.log('Widget opened'));
chatBox.on('close', () => console.log('Widget closed'));
chatBox.on('message', (data) => console.log('Message received:', data));