Website Advanced Guide

The website channel supports more configurations based on the LiveDesk Widget SDK interface to meet user needs.

LiveDesk Widget SDK Interface

Set Userid and User Information (Normal Mode)

window.addEventListener("livedesk:ready", function () { window.$livedesk.setUser("User Unique ID (e.g. user_id)", { // First parameter is 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 () {
  window.$livedesk.setUser("User Unique ID (e.g. user_id)", {  // First parameter is unique identifier
    email: "user@example.com",
    name: "User Name",
    avatar_url: "https://example.com/avatar.jpg",  // Optional
    phone_number: "+1234567890"  // Optional
  });
});

            
This code block in the floating window

Set Userid and User Information (Encrypted Mode)

Enable authentication (recommended): To prevent forgery and ensure session persistence across browsers, enable HMAC in the configuration (use SHA256 to generate identifier_hash). Example (JavaScript):

const crypto = require('crypto'); const key = 'Your HMAC Token'; // Copy from Inboxes settings const message = 'User Unique ID'; const identifier_hash = crypto.createHmac('sha256', key).update(message).digest('hex'); // Attach in setUser window.$livedesk.setUser("User Unique ID", { ...other info, identifier_hash: identifier_hash });
              
              const crypto = require('crypto');
const key = 'Your HMAC Token';  // Copy from Inboxes settings
const message = 'User Unique ID';
const identifier_hash = crypto.createHmac('sha256', key).update(message).digest('hex');

// Attach in setUser
window.$livedesk.setUser("User Unique ID", {
  ...other info,
  identifier_hash: identifier_hash
});

            
This code block in the floating window

Set "Conversation Custom Attributes"

window.$livedesk.setConversationCustomAttributes({ utm_source: "google", // Example: Session level UTM session_type: "support" });
              
              window.$livedesk.setConversationCustomAttributes({
  utm_source: "google",  // Example: Session level UTM
  session_type: "support"
});

            
This code block in the floating window
  • These custom variables are displayed in Livedesk - Conversation - Conversation Information.

Set "Contact Custom Attributes"

window.addEventListener("livedesk:ready", function () { window.$livedesk.setCustomAttributes({ pricing_plan: "premium", // key: Predefined unique identifier, value: set according to type (e.g., string) signup_date: new Date(), // Example: Date type account_id: 123 // Example: Number type }); });
              
              window.addEventListener("livedesk:ready", function () {
  window.$livedesk.setCustomAttributes({
    pricing_plan: "premium",  // key: Predefined unique identifier, value: set according to type (e.g., string)
    signup_date: new Date(),  // Example: Date type
    account_id: 123           // Example: Number type
  });
});

            
This code block in the floating window
  • These custom variables are displayed in "Livedesk - Conversation - Contact Attributes".

Delete User Attribute

Delete the specified custom attribute.

window.$livedesk.deleteCustomAttribute("pricing_plan");//string attribute key name
              
              window.$livedesk.deleteCustomAttribute("pricing_plan");//string attribute key name

            
This code block in the floating window

Toggle Chat Bubble Open State

Toggle the open/close state of the widget.

window.$livdesk.toggle(); // Toggle widget by passing state window.$livedesk.toggle("open"); // Open chat widget window.$livedesk.toggle("close"); // Close chat widget
              
              window.$livdesk.toggle();

// Toggle widget by passing state
window.$livedesk.toggle("open"); // Open chat widget
window.$livedesk.toggle("close"); // Close chat widget

            
This code block in the floating window

Show/Hide Chat Bubble

window.$livedesk.toggleBubbleVisibility('hide');// show/hide
              
              window.$livedesk.toggleBubbleVisibility('hide');// show/hide

            
This code block in the floating window

Popout Mode

Open the chat interface in popout window mode.

window.$livedesk.popoutChatWindow();
              
              window.$livedesk.popoutChatWindow();

            
This code block in the floating window

Set Language

Set the widget language

window.$livedesk.setLocale("en");// string language code, example: zh-CN
              
              window.$livedesk.setLocale("en");// string language code, example: zh-CN

            
This code block in the floating window

Add/Remove Labels

Add a label to the current conversation (before the conversation starts), the label will be automatically set to the conversation

window.$livdesk.setLabel('support-ticket');// string label identifier window.$livdesk.removeLabel('support-ticket');
              
              window.$livdesk.setLabel('support-ticket');// string label identifier
window.$livdesk.removeLabel('support-ticket');

            
This code block in the floating window

Livedesk Widget Configuration Object

Global object set during initialization (before loading SDK) for customizing widget behavior. Defined via window.livedeskSettings and then passed in window.livedeskSDK.run().

Object Properties

Property Name Type Description Default Value Example
hideMessageBubble boolean Hide message bubble. false true
showUnreadMessagesDialog boolean Show unread messages dialog. true false
position string Widget position. 'right' 'left'
locale string Default language code. Dashboard language 'zh-CN'
useBrowserLanguage boolean Use browser language (ignore locale). false true
type string Widget type. 'standard' 'expanded_bubble'
darkMode boolean Enable dark mode. false true
baseDomain string Base domain (optional, for multi-domain). - 'example.com'
launcherTitle string Launcher title. - 'Support'
showPopoutButton boolean Show popout 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 upload. true false
enableEmojiPicker boolean Enable emoji picker. true false
enableEndConversation boolean Enable end conversation button. true false

Example Code

<script> // 1. Set global configuration before loading sdk.js (must be placed at the very beginning of the script) window.livedeskSettings = { // Widget position: bottom left (default is bottom right) position: "left", // Force language to Simplified Chinese (will display Chinese even if browser is English) locale: "zh-CN", // Automatically detect browser language (if you want to prioritize user browser language, set to true and delete locale above) // useBrowserLanguage: true, // Widget type: expanded_bubble = large bubble (with welcome message), standard = classic small bubble type: "expanded_bubble", // Dark mode (auto follow system or force dark) darkMode: "auto", // Optional values: true | false | "auto" // Hide the small bubble icon at the bottom (suitable for placing in custom buttons) hideMessageBubble: false, // Hide the "popout window" small 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/offline availableMessage: "We are online, ready to serve you", unavailableMessage: "We are currently offline, will reply as soon as possible during business hours", // Feature switches enableFileUpload: true, // Allow file upload enableEmojiPicker: true, // Allow using emojis enableEndConversation: true, // Allow user to actively end conversation // Other advanced options (open as needed) // showUnreadMessagesDialog: true, // Pop-up reminder when there are unread messages (default true) // baseDomain: "yourcompany.com", // Use for multi-domain deployment }; </script> <!-- 2. Load 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),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>
              
              <script>
// 1. Set global configuration before loading sdk.js (must be placed at the very beginning of the script)
window.livedeskSettings = {
  // Widget position: bottom left (default is bottom right)
  position: "left",

  // Force language to Simplified Chinese (will display Chinese even if browser is English)
  locale: "zh-CN",

  // Automatically detect browser language (if you want to prioritize user browser language, set to true and delete locale above)
  // useBrowserLanguage: true,

  // Widget type: expanded_bubble = large bubble (with welcome message), standard = classic small bubble
  type: "expanded_bubble",

  // Dark mode (auto follow system or force dark)
  darkMode: "auto",        // Optional values: true | false | "auto"

  // Hide the small bubble icon at the bottom (suitable for placing in custom buttons)
  hideMessageBubble: false,

  // Hide the "popout window" small 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/offline
  availableMessage: "We are online, ready to serve you",
  unavailableMessage: "We are currently offline, will reply as soon as possible during business hours",

  // Feature switches
  enableFileUpload: true,       // Allow file upload
  enableEmojiPicker: true,      // Allow using emojis
  enableEndConversation: true,  // Allow user to actively end conversation

  // Other advanced options (open as needed)
  // showUnreadMessagesDialog: true,   // Pop-up reminder when there are unread messages (default true)
  // baseDomain: "yourcompany.com",    // Use for multi-domain deployment
};

</script>

<!-- 2. Load 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),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>

            
This code block in the floating window

Livedesk Widget Event Listening

Event Name Description Listening Example
livedesk:ready SDK fully loaded, safe to call methods. window.addEventListener('livedesk:ready', () => { /* Initialize */ });
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); });
icon
Contact Sales