Advanced Website Usage Guide
The Website channel supports additional configuration through the LiveDesk Widget SDK interface or by using an iframe to meet your requirements.
iframe-Related Settings
Skip the Welcome Screen
In iframe mode, you can add the action=autoStart parameter to skip the welcome screen that appears when the bubble opens and enter the chat window directly.
<iframe
class="livedesk-widget-iframe"
src="https://livedesk-stg.engagelab.com/console/livedesk/widget/?website_token=iTMtGDnzR1tccf3fiikLjL71&action=autoStart"
title="LiveDesk"
allow="camera;microphone"
/>
website_tokenspecifies the corresponding value generated after the channel is created.
Set the User ID
Two configuration methods are available.
Method 1:
Array.from(document.getElementsByTagName('iframe'))
.filter((iframe) => iframe.src && iframe.src.includes('livedesk'))
.forEach((iframe) =>
iframe.contentWindow?.postMessage(
'livedesk-widget:' +
JSON.stringify({
event: 'set-user',
identifier: 'your_user_id',
user: { name: 'Display name', email: 'user@example.com' },
}),
'*',
),
);
Method 2: Add the user_id=xxxxx parameter to the iframe.
<iframe
class="livedesk-widget-iframe"
src="https://livedesk-stg.engagelab.com/console/livedesk/widget/?website_token=Etsz4XtvqKi7iqbHf8Ma6ZLR&action=autoStart&user_id=5002"
title="LiveDesk"
allow="camera;microphone"
/>
LiveDesk Widget SDK Interface
Set the User ID and User Information (Standard Mode)
window.addEventListener("livedesk:ready", function () {
window.$livedesk.setUserId("Unique user ID (such as user_id)", {
// The first parameter is the unique identifier
email: "user@example.com",
name: "User name",
avatar_url: "https://example.com/avatar.jpg", // Optional
phone_number: "+1234567890", // Optional
});
});
window.addEventListener("livedesk:ready", function ()) event listener.
Set the User ID and User Information (Encrypted Mode)
Enable authentication (recommended) to prevent spoofing and ensure session persistence across browsers. Enable HMAC in the configuration and use SHA-256 to generate identifier_hash.
Example (JavaScript):
const crypto = require("crypto");
const key = "Your HMAC Token"; // Copy from Inboxes settings
const message = "Unique user ID";
const identifier_hash = crypto
.createHmac("sha256", key)
.update(message)
.digest("hex");
// Append to setUser
window.$livedesk.setUserId("Unique user ID", {
...OtherInformation,
identifier_hash: identifier_hash,
});
Set Conversation Custom Attributes
window.$livedesk.setConversationCustomAttributes({
utm_source: "google", // Example: conversation-level UTM
session_type: "support",
});
These custom attributes are displayed in LiveDesk > Conversation > Conversation Information.
Set User Custom Attributes
window.addEventListener("livedesk:ready", function () {
window.$livedesk.setCustomAttributes({
pricing_plan: "premium", // Key: predefined unique identifier; value: set according to the type, such as a string
signup_date: new Date(), // Example: date type
account_id: 123, // Example: number type
});
});
These custom attributes are displayed in LiveDesk > Conversation > Contact Attributes.
Delete User Attributes
Delete the specified custom attribute.
window.$livedesk.deleteCustomAttribute("pricing_plan"); // String attribute key
Toggle the Chat Bubble's Open State
Toggle the widget's open or closed state.
window.$livedesk.toggle();
// Toggle the widget by passing a state
window.$livedesk.toggle("open"); // Open the chat widget
window.$livedesk.toggle("close"); // Close the chat widget
Show or Hide the Chat Bubble
window.$livedesk.toggleBubbleVisibility("hide"); // Show or hide
Pop-Up Mode
Open the chat interface in a pop-up window.
window.$livedesk.popoutChatWindow();
Set the Language
Set the widget language.
window.$livedesk.setLocale("en"); // String language code, such as zh-CN
Add or Remove Labels
Add a label to the current conversation before the conversation starts. The label will be automatically applied to the conversation.
window.$livedesk.setLabel("support-ticket"); // String label identifier
window.$livedesk.removeLabel("support-ticket");
LiveDesk Widget Configuration Object
This global object is set during initialization, before the SDK is loaded, to customize widget behavior. Define it using window.livedeskSettings, then pass it to window.livedeskSDK.run().
Object Properties
| Property Name | Type | Description | Default Value | Example |
|---|---|---|---|---|
hideMessageBubble |
boolean | Hide the message bubble. | false |
true |
showUnreadMessagesDialog |
boolean | Show the unread messages dialog. | true |
false |
position |
string | Widget position. | 'right' |
'left' |
locale |
string | Default language code. | Dashboard language | 'zh-CN' |
useBrowserLanguage |
boolean | Use the browser language and ignore locale. |
false |
true |
type |
string | Widget type. | 'standard' |
'expanded_bubble' |
darkMode |
boolean | Enable dark mode. | false |
true |
baseDomain |
string | Base domain, optional for multiple domains. | — | 'example.com' |
launcherTitle |
string | Launcher title. | — | 'Support' |
showPopoutButton |
boolean | Show the pop-up button. | true |
false |
welcomeTitle |
string | Welcome title. | — | 'Welcome!' |
welcomeDescription |
string | Welcome description. | — | 'How can we help you?' |
availableMessage |
string | Online message. | — | 'We are online.' |
unavailableMessage |
string | Offline message. | — | 'We will reply later.' |
enableFileUpload |
boolean | Enable file uploads. | true |
false |
enableEmojiPicker |
boolean | Enable the emoji picker. | true |
false |
enableEndConversation |
boolean | Enable the end conversation button. | true |
false |
Example Code
<script>
// 1. Set the global configuration before loading sdk.js.
// This must be placed at the beginning of the script.
window.livedeskSettings = {
// Widget position: bottom-left (bottom-right by default)
position: "left",
// Force Simplified Chinese (Chinese will be displayed even if the browser is set to English)
locale: "zh-CN",
// Automatically detect the browser language. If you want to prioritize
// the user's browser language, set this to true and delete the locale above.
// useBrowserLanguage: true,
// Widget type: expanded_bubble = large bubble with a welcome message;
// standard = classic small bubble
type: "expanded_bubble",
// Dark mode (automatically follow the system setting or force dark mode)
darkMode: "auto", // Optional values: true | false | "auto"
// Hide the small bubble icon at the bottom (suitable for use with a custom button)
hideMessageBubble: false,
// Hide the pop-up window arrow button in the bottom-right corner
showPopoutButton: false,
// Custom launcher title (displayed in expanded_bubble mode)
launcherTitle: "Online Support",
// Welcome message (effective in expanded_bubble mode)
welcomeTitle: "Hello! How can we help you?",
welcomeDescription: "We usually reply within a few minutes.",
// Prompt text displayed when online or offline
availableMessage: "We are online and ready to help",
unavailableMessage:
"We are currently offline and will reply as soon as possible during business hours",
// Feature toggles
enableFileUpload: true, // Allow file uploads
enableEmojiPicker: true, // Allow emojis
enableEndConversation: true, // Allow users to end the conversation themselves
// Other advanced options (enable as needed)
// showUnreadMessagesDialog: true, // Show a reminder dialog when there are unread messages (true by default)
// baseDomain: "yourcompany.com", // Use for multi-domain deployments
};
</script>
<!-- 2. Load the LiveDesk Widget SDK (replace with your own domain and token) -->
<script>
(function (d, t) {
var BASE_URL = "https://www.engagelab.com"; // Change to your LiveDesk address
var g = d.createElement(t);
var s = d.getElementsByTagName(t)[0];
g.src = BASE_URL + "/packs/js/sdk.js";
g.defer = true;
g.async = true;
s.parentNode.insertBefore(g, s);
g.onload = function () {
window.livedeskSDK.run({
websiteToken: "abcdefgh1234567890abcdefgh123456", // Change to your Website Token
baseUrl: BASE_URL,
});
};
})(document, "script");
</script>
LiveDesk Widget Event Listeners
| Event Name | Description | Listener Example |
|---|---|---|
livedesk:ready |
Triggered when the SDK has finished loading and its methods can be called safely. | window.addEventListener('livedesk:ready', () => { /* Initialization */ }); |
livedesk:on-message |
Triggered when a new message is received. | window.addEventListener('livedesk:on-message', (data) => { console.log(data); }); |
livedesk:error |
Triggered when an SDK error occurs (v2.3.0+). | window.addEventListener('livedesk:error', (error) => { console.error(error); }); |










