Installation
Get the DialogKit ChatBox SDK running on your website in just a few minutes.
Prerequisites
Before you begin, you'll need:
- A DialogKit account (sign up at app.dialogkit.io)
- An API key from your Design Studio
- A published conversational flow
Script Tag Method (Recommended)
The simplest way to add ChatBox SDK to your site is with a single script tag:
<script
src="https://cdn.dialogkit.io/chatbox-sdk.min.js"
data-api-key="YOUR_API_KEY"
></script>
Place this script tag just before the closing </body> tag in your HTML.
Script Tag Attributes
Customize the widget behavior using data attributes:
| Attribute | Required | Description | Default |
|---|---|---|---|
data-api-key | Yes | Your API key from Design Studio | - |
data-position | No | Widget position on screen | bottom-right |
data-theme | No | Color theme | light |
data-flow-id | No | Specific flow to start | Auto-selected |
Example with Customization
<script
src="https://cdn.dialogkit.io/chatbox-sdk.min.js"
data-api-key="YOUR_API_KEY"
data-position="bottom-left"
data-theme="dark"
></script>
JavaScript Method
For more control, initialize the SDK programmatically:
// Load the SDK script
const script = document.createElement('script');
script.src = 'https://cdn.dialogkit.io/chatbox-sdk.min.js';
document.head.appendChild(script);
// Wait for SDK to load, then initialize
script.onload = () => {
const chatbox = new ChatBoxSDK({
apiKey: 'YOUR_API_KEY',
position: 'bottom-right',
theme: {
primaryColor: '#0066FF',
fontFamily: 'Inter, sans-serif'
},
context: {
userId: '12345',
userName: 'John Doe'
}
});
// Optional: Listen to events
chatbox.on('ready', () => {
console.log('ChatBox is ready');
});
chatbox.on('message', (data) => {
console.log('Message sent:', data);
});
};
NPM Method
If you're using a build tool like Webpack or Vite:
npm install @dialogkit/chatbox-sdk
import ChatBoxSDK from '@dialogkit/chatbox-sdk';
import '@dialogkit/chatbox-sdk/dist/styles.css';
const chatbox = new ChatBoxSDK({
apiKey: 'YOUR_API_KEY'
});
note
The NPM package is coming soon. For now, use the CDN method.
Getting Your API Key
- Log in to Design Studio
- Navigate to Settings > API Keys
- Click Generate New Key
- Copy your API key
Security
Never commit API keys to version control. Use environment variables in production:
apiKey: process.env.DIALOGKIT_API_KEY
Verifying Installation
After adding the script, you should see:
- A chat bubble appearing in the bottom-right (or your specified position)
- Clicking the bubble opens your conversational flow
- The widget is responsive and works on mobile devices
Troubleshooting
Widget Not Appearing
Check browser console for errors:
- API key invalid → Verify key in Design Studio
- Flow not published → Publish at least one flow
- CORS errors → Contact support
Performance Issues
Optimize loading:
- Place script tag at end of
<body> - Use
asyncattribute for non-blocking load - Ensure your flow is optimized (avoid large images)
Browser Compatibility
The ChatBox SDK supports:
- Chrome 90+
- Firefox 88+
- Safari 14+
- Edge 90+
Next Steps
- First Chatbot - Create your first conversation in 5 minutes
- Configuration - Customize widget appearance and behavior
- API Reference - Complete SDK documentation