The simplest way to get started with ChatBox SDK. Perfect for quick integration and testing.
Follow these simple steps to integrate ChatBox SDK into any website:
<!-- 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>
<script>
window.ChatBoxConfig = {
apiKey: 'your-api-key-here',
theme: {
primaryColor: '#007bff',
secondaryColor: '#6c757d'
},
ui: {
title: 'Customer Support',
subtitle: 'We\'re online now'
}
};
</script>
The SDK will automatically initialize and display a chat button in your chosen position (default: bottom-right).
Use the configuration panel at the top to:
Required:
apiKey - Your unique API key for the serviceOptional:
userId - Unique identifier for the user (auto-generated if not provided)userMetadata - Additional user information (name, email, custom fields)context - Page or session context (current page, order ID, etc.)theme - Visual customization (colors, dark mode)ui - Text customization (title, subtitle, placeholder)layout - Widget positioning and typebehavior - Widget behavior settings (auto-open, remember state)Once you're comfortable with the basics, check out these examples:
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));