Logo Site EngageLab Mark Colored TransparentDocument
Search

Website Advanced Usage Guide

The Website channel supports additional configuration options through the LiveDesk Widget SDK interface or by using an iframe to meet different user needs.

Skip the Welcome Screen

In iframe mode, users can skip the welcome screen when opening the bubble by adding the parameter action=autoStart, which takes them directly to the chat box to start a conversation.

<iframe class="livedesk-widget-iframe" src="https://livedesk-stg.engagelab.com/console/livedesk/widget/?website_token=iTMtGDnzR1tccf3fiikLjL71&action=autoStart" // Replace website_token with the corresponding value generated after creating the channel title="Live desk" allow="camera;microphone" />
              
              <iframe
    class="livedesk-widget-iframe"
    src="https://livedesk-stg.engagelab.com/console/livedesk/widget/?website_token=iTMtGDnzR1tccf3fiikLjL71&action=autoStart" // Replace website_token with the corresponding value generated after creating the channel
    title="Live desk"
    allow="camera;microphone"
/>

            
This code block in the floating window

Set 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' }, }), '*', ), );
              
              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' },
}),
'*',
),
);

            
This code block in the floating window

Method 2: Add the parameter user_id=xxxxx 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" />
              
              <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"
/>

            
This code block in the floating window

LiveDesk Widget SDK Interface

Set 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 () {
  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
  });
});

            
This code block in the floating window
Note: If setting the user ID in the configuration is triggered by the end user, you can remove the window.addEventListener("livedesk:ready", function ()) event wrapper.

Set User ID and User Information (Encrypted Mode)

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

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

// Attach in setUser
window.$livedesk.setUserId("Unique user ID", {
  ...Other information,
  identifier_hash: identifier_hash
});

            
This code block in the floating window

Set Conversation Custom Variables

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

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

Set User Custom Variables

window.addEventListener("livedesk:ready", function () { window.$livedesk.setCustomAttributes({ pricing_plan: "premium", // key: predefined unique identifier; value: set according to type (such as 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 (such as 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 Attributes

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 the Chat Bubble Open State

Toggle the widget open/close state.

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

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

            
This code block in the floating window

Show/Hide the Chat Bubble

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

            
This code block in the floating window

Pop-Out Mode

Open the chat interface in pop-out 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, for example: zh-CN
              
              window.$livedesk.setLocale("en"); // String language code, for example: zh-CN

            
This code block in the floating window

Add/Remove Labels

Add labels to the current session (before the conversation starts). The labels will be automatically applied 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

A global object set during initialization (before loading the SDK) to customize widget behavior. Define it through window.livedeskSettings, then pass it to window.livedeskSDK.run().

Object Properties

Property Name Type Description Default Value Example
hideMessageBubble boolean Hides the message bubble. false true
showUnreadMessagesDialog boolean Shows the unread messages dialog. true false
position string Widget position. 'right' 'left'
locale string Default language code. Dashboard language 'zh-CN'
useBrowserLanguage boolean Uses the browser language (ignores locale). false true
type string Widget type. 'standard' 'expanded_bubble'
darkMode boolean Enables dark mode. false true
baseDomain string Base domain (optional, for multiple domains). - 'example.com'
launcherTitle string Launcher title. - 'Support'
showPopoutButton boolean Shows the pop-out 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 Enables file upload. true false
enableEmojiPicker boolean Enables the emoji picker. true false
enableEndConversation boolean Enables the end conversation button. true false

Example Code

<script> // 1. Before loading sdk.js, set the global configuration first (must be placed at the beginning of the script) window.livedeskSettings = { // Widget position: bottom-left (default is bottom-right) position: "left", // Force the language to Simplified Chinese (it will display Chinese even if the browser is in English) locale: "zh-CN", // Automatically detect the browser language (if you want to prioritize the user's browser language, set to true and remove the locale above) // useBrowserLanguage: true, // Widget type: expanded_bubble = large bubble (with welcome message), standard = classic small bubble type: "expanded_bubble", // Dark mode (follow the system automatically or force dark mode) darkMode: "auto", // Optional values: true | false | "auto" // Hide the small bubble icon at the bottom (suitable for placement in a custom button) hideMessageBubble: false, // Hide the "pop-out window" arrow button in the bottom-right corner showPopoutButton: false, // Custom launcher title (displayed in large bubble mode) launcherTitle: "Online Support", // Welcome message (takes effect in expanded_bubble mode) welcomeTitle: "Hello! How can we help you?", welcomeDescription: "We usually reply within a few minutes.", // Prompt text shown when online/offline availableMessage: "We are online and ready to assist you at any time", unavailableMessage: "We are currently offline and will reply as soon as possible during business hours", // Feature switches enableFileUpload: true, // Allow file uploads enableEmojiPicker: true, // Allow emoji usage enableEndConversation: true, // Allow users to end the conversation proactively // Other advanced options (enable as needed) // showUnreadMessagesDialog: true, // Pop-up reminder when there are unread messages (default: true) // baseDomain: "yourcompany.com", // Used for multi-domain deployment }; </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"; // ← Replace with 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', // ← Replace with your Website Token baseUrl: BASE_URL }); } })(document,"script"); </script>
              
              <script>
// 1. Before loading sdk.js, set the global configuration first (must be placed at the beginning of the script)
window.livedeskSettings = {
  // Widget position: bottom-left (default is bottom-right)
  position: "left",

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

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

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

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

  // Hide the small bubble icon at the bottom (suitable for placement in a custom button)
  hideMessageBubble: false,

  // Hide the "pop-out window" arrow button in the bottom-right corner
  showPopoutButton: false,

  // Custom launcher title (displayed in large bubble mode)
  launcherTitle: "Online Support",

  // Welcome message (takes effect in expanded_bubble mode)
  welcomeTitle: "Hello! How can we help you?",
  welcomeDescription: "We usually reply within a few minutes.",

  // Prompt text shown when online/offline
  availableMessage: "We are online and ready to assist you at any time",
  unavailableMessage: "We are currently offline and will reply as soon as possible during business hours",

  // Feature switches
  enableFileUpload: true,       // Allow file uploads
  enableEmojiPicker: true,      // Allow emoji usage
  enableEndConversation: true,  // Allow users to end the conversation proactively

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

</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";          // ← Replace with 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',  // ← Replace with your Website Token
        baseUrl: BASE_URL
      });
    }
  })(document,"script");
</script>

            
This code block in the floating window

LiveDesk Widget Event Listeners

Event Name Description Listener Example
livedesk:ready Triggered when the SDK is fully loaded and methods can be safely called. 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); });
Icon Solid Transparent White Qiyu
Contact Sales