Chat Widget - Quick Start Guide
Get the dialektai chat widget embedded on your website in under 5 minutes.
What You'll Need
- A dialektai account with at least one connected database
- A website where you can add HTML/JavaScript
- 5 minutes
Step 1: Get Your API Key
- Log in to the dialektai portal
- Navigate to your database details page
- Scroll to the Widget Integration section
- Click Generate API Key
- Give it a name (e.g., "Website Widget")
- Copy the API key (it's shown only once!)
Step 2: Configure CORS
Add your website domain to allowed origins:
- In the same Widget Integration section
- Find Allowed Origins
- Add your domain:
https://yourwebsite.com - Click Save
Important: Use your actual domain, not localhost (unless testing)
Step 3: Add Widget to Your Website
Add this code to your HTML where you want the chat widget:
<!-- Container for the widget -->
<div data-dialekt-ai-widget
data-api-key="YOUR_API_KEY_HERE"
data-database-id="YOUR_DATABASE_ID"
data-theme="light"
data-position="bottom-right">
</div>
<!-- Widget script -->
<script src="https://widget.dialektai.com/widget.js"></script>
Replace:
YOUR_API_KEY_HEREwith the API key from Step 1YOUR_DATABASE_IDwith your database ID (optional, can select in widget)
Step 4: Test It!
- Open your website in a browser
- Look for the chat bubble in the bottom-right corner
- Click to open the widget
- Ask a question about your database!
Example questions:
- "How many records are in the customers table?"
- "Show me the latest 5 orders"
- "What's the total revenue this month?"
Customization Options
Change Theme
data-theme="dark" <!-- Dark mode -->
data-theme="light" <!-- Light mode (default) -->
data-theme="auto" <!-- Follows system preference -->
Change Position
data-position="bottom-right" <!-- Default -->
data-position="bottom-left"
data-position="top-right"
data-position="top-left"
Custom Placeholder
data-placeholder="Ask me about your sales data..."
Use Specific AI Personality
data-personality-id="a1201dbc-0d37-4c74-8ea0-235f7466162b"
How to get your Personality ID:
- Log in to the dialektai portal
- Go to Settings → AI Personalities
- Find the personality you want to use
- Click the Copy button next to the Personality ID
Set Widget Height
data-height="500" <!-- Height in pixels -->
Automatic Branding (Business+ Plans)
The widget automatically applies your organization's branding - no additional configuration needed!
Included with automatic branding:
- Custom logo in widget header
- Your brand colors throughout the interface
- Custom placeholder text and greeting message
- Widget positioning from your preferences
How to set up:
- Log in to the dialektai portal
- Navigate to Settings → Branding
- Upload your logo and customize colors
- Save changes
- Your widget updates automatically!
Plan Requirements:
- Custom Colors & Logo: Business or Enterprise plan
- Hide "Powered by dialektai": Enterprise plan only
Example widget with automatic branding:
<!-- Widget automatically applies your branding -->
<div data-dialekt-ai-widget
data-api-key="pk_key_abc123..."
data-database-id="550e8400-e29b-41d4-a716-446655440000">
</div>
<script src="https://widget.dialektai.com/widget.js"></script>
That's it! Your custom logo, colors, and settings are applied automatically.
See Branding Configuration Guide for detailed setup instructions.
Complete Example
<!DOCTYPE html>
<html>
<head>
<title>My Website with dialektai</title>
</head>
<body>
<h1>Welcome to My Site</h1>
<!-- dialektai Chat Widget -->
<div data-dialekt-ai-widget
data-api-key="pk_key_abc123..."
data-database-id="550e8400-e29b-41d4-a716-446655440000"
data-theme="auto"
data-position="bottom-right"
data-placeholder="Ask about our data...">
</div>
<script src="https://widget.dialektai.com/widget.js"></script>
</body>
</html>
Troubleshooting
Widget Not Showing
- Check console for errors: Open browser DevTools (F12) → Console tab
- Verify API key: Ensure it's correct and not revoked
- Check CORS: Make sure your domain is in allowed origins
- Script loaded: Verify
widget.jsloaded successfully in Network tab
"Unauthorized" Error
- API key is incorrect or revoked
- Domain not in CORS allowed origins
- Database API key used with wrong database ID
Widget Shows But Won't Query
- Database not connected or schema indexing failed
- Database requires tenant filtering but no
data-tenant-idprovided - Check API key permissions
Advanced Integration
For programmatic control, use the JavaScript API:
// Create widget in specific container
const widgetId = DialektAI.create('#my-chat-container', {
apiKey: 'your-api-key',
databaseId: 'your-db-id',
theme: 'auto'
});
console.log('Widget created with ID:', widgetId);
// Destroy widget when needed
DialektAI.destroy(widgetId);
// Using embed() for callbacks (advanced)
const embedWidgetId = DialektAI.embed({
containerId: 'my-chat-container',
apiKey: 'your-api-key',
databaseId: 'your-db-id',
theme: 'auto',
onReady: () => console.log('Widget ready!'),
onError: (error) => console.error('Error:', error)
});
Multi-tenant Support
If you have a multi-tenant application (SaaS), filter data by customer:
<div data-dialekt-ai-widget
data-api-key="YOUR_API_KEY"
data-database-id="YOUR_DB_ID"
data-tenant-id="customer-123"
data-scope-id="550e8400-e29b-41d4-a716-446655440000">
</div>
- tenant-id: Filters database queries to this customer's data
- Accepts any string format (integers, UUIDs, custom strings)
- Examples:
"82","customer-123","550e8400-e29b-41d4-a716-446655440000"
- scope-id: Identifies the user for conversation history
- Accepts any string format (UUIDs, usernames, numbers, etc.)
- Examples:
"550e8400-e29b-41d4-a716-446655440000","user-456","[email protected]"
Note: Your database must have requires_organization_scoping = true enabled in the configuration.
Next Steps
- Widget Integration Guide - Complete widget setup guide
- API Keys Guide - Authentication and key management
- API Integration Guide - Direct API integration for custom UIs
Last updated: 2025-11-06