Widget configuration
Configure the DGbot widget's appearance, position, and identity verification via script attributes and the JS API.
Data attributes
Configure the widget's initial state via data-* attributes on the script tag:
| Attribute | Type | Default | Description |
|---|---|---|---|
data-chatbot-id | string | required | Your chatbot's unique identifier |
data-position | string | bottom-right | Widget position: bottom-right or bottom-left |
data-theme | string | light | Widget theme: light or dark |
data-open | boolean | false | Open the widget automatically on page load |
data-hide-launcher | boolean | false | Hide the launcher bubble (use with JS API to control opening) |
Example — dark mode widget on the left:
<script src="https://dgbot.dgtech.co.in/static/widget.js" data-chatbot-id="YOUR_CHATBOT_ID" data-position="bottom-left" data-theme="dark" defer ></script>
Identity verification
When you know who your logged-in visitor is (from your own auth system), you can pass verified user identity to DGbot. This enables personalised responses (calling the visitor by name) and secure integrations (passing the user's account data to custom API actions).
Why verification matters: Without verification, any visitor could claim to be any user by passing arbitrary data to the widget. Verification uses HMAC-SHA256 signing to prove the identity payload came from your server.
Go to Settings → Embed in the admin panel. Copy the HMAC secret — this is a server-side secret, never expose it in client-side code.
Open Settings in adminYour server generates an HMAC-SHA256 signature of the visitor's ID using your secret:
# Python example
import hmac, hashlib
def sign_visitor(visitor_id: str, hmac_secret: str) -> str:
return hmac.new(
hmac_secret.encode('utf-8'),
visitor_id.encode('utf-8'),
hashlib.sha256
).hexdigest()// Node.js example
const crypto = require('crypto')
function signVisitor(visitorId, hmacSecret) {
return crypto.createHmac('sha256', hmacSecret)
.update(visitorId)
.digest('hex')
}Pass the signed identity as part of widget initialisation. This is done via the JS API after the widget loads:
window.DGbot('identify', {
userId: 'user_12345',
name: 'Jane Smith',
email: 'jane@example.com',
userHash: 'SERVER_GENERATED_HMAC_SIGNATURE'
})Only userId and userHash are required. name and email are optional but enable personalised responses.
JS initialization
If you prefer JS-based initialisation over data attributes, use the init command:
window.DGbot('init', {
chatbotId: 'YOUR_CHATBOT_ID',
position: 'bottom-right',
theme: 'light',
open: false
})The window.DGbot function is available after the widget script loads. To safely call it before the script has finished loading, queue commands with the standard pattern:
window.DGbot = window.DGbot || function() {
(window.DGbot.q = window.DGbot.q || []).push(arguments)
}
window.DGbot('init', { chatbotId: 'YOUR_CHATBOT_ID' })