The Gladly Sidekick is an embeddable UI element that lives on your website and allows customers to search for answers or talk and interact with your team in real-time. The Gladly Sidekick API enables you to have programmatic control of the Gladly Sidekick.

JavaScript snippet

Add the following JavaScript embed code to all your site’s pages, preferably at the bottom of the page to avoid slowing down the main page content to load. This will load the code that powers the Gladly Sidekick on your site.

Note that the fourth argument of the snippet below specifies 'PROD' which enables you to use the latest release of the Chat-SDK with your production appId.

  (function(c,n,i,t){var p;var s=[];var l;if(t==="PROD"||!t){l=""}else if(t==="STAGING"){l=""}else{l=t}c[i]={init:function(){p=arguments;var e={then:function(t){s.push({type:"t",next:t});return e},catch:function(t){s.push({type:"c",next:t});return e}};return e}};function e(){try{var t=n.getElementsByTagName("script")[0];var e=n.createElement("script");e.async=true;e.src=l+"?q="+(new Date).getTime();t.parentNode.insertBefore(e,t)}catch(t){}}c.__onGladlyHostReady__=function t(e){delete c.__onGladlyHostReady__;c[i]=e;e.loaderCdn=l;if(p){var n=e.init.apply(e,p);for(var a=0;a<s.length;a++){var r=s[a];if(r.type==="t"){n=n.then(}else{n=n.catch(}}}};e()})


In order to start the Gladly Sidekick on your site, you must initialize it after you load the above JavaScript embed code.

Basic Initialization:

Add the following script tag to your page to automatically initialize the Gladly Sidekick. This is most appropriate if you do not want to take advantage of any Gladly API functionality and just want to display a basic widget. Work with your Gladly CSM to get the “your-own-id” value.

 window.gladlyConfig = {
   appId: 'your-own-id'

Manual Initialization:

Sidekick can be manually initialized to get better control over when to display the Sidekick. This could be desirable, for example, if you want to start the Sidekick from your own button.

For a more dynamic interaction, Sidekick exposes an Availability state that allows the site to change the behavior depending on if chat is closed or if it's unavailable due to high demand.

The example below initializes the Sidekick, then checks to see if chat is available and sets a class on a button assumed to exist on the page.

  appId: "your-own-id"
}).then(function() {
  // This is called once Sidekick has been initialized.

  // An element with the id "start-chat" is assumed to be on the page.
  var startChatButton = document.getElementById('start-chat');

  // An onClick handler can be attached to the "start-chat" element
  startChatButton.onclick = function() {};

  // This API call gets the current availability
  var availablility = Gladly.getAvailability();

  // Setting the availability as the class name on the "start-chat" element,
  // this allows us to change the look of the button via CSS.
  startChatButton.setAttribute('class', availablility.toLowerCase());

  // Subscribe to changes in availability, and update the class on the "start-chat" element.
  Gladly.on('availability:change', function(availablility) {
    startChatButton.setAttribute('class', availablility.toLowerCase());
}).catch(function(error) {
  // If anything goes wrong when Sidekick is being initialized, this gets called.
  console.log('error:', error)

Browser Support

The Gladly Sidekick supports major browsers. For the desktop, we support current + previous major versions of Chrome, Firefox, and Safari along with IE11 and the current version of Microsoft Edge. For mobile, we support current + previous major versions of Chrome on Android and iOS and the current + previous versions of Safari on iOS.

Working with Sandbox / Staging Environment

You can use our sandbox environment to test upcoming Chat-SDK releases or new configuration on your staging site. To launch the Gladly Sidekick on your staging site, follow the steps above to add the JavaScript embed code and initialize. Then make following modification:

Change the value in this part of your embed code to 'STAGING':


Deployment Checklist

  1. Add embed code to correct environment
  2. Add embed code only once to each page
  3. Initialize the Sidekick by either defining window.gladlyConfig OR calling Gladly.init(), never both

Custom Minimized Button

Gladly allows you to customize the minimized chat button that is rendered on your site to better align with your brand. There are a few simple steps to implement a custom minimized chat button.

  1. Gladly requires that an HTML id of custom-gladly-chat-button be specified on the outermost HTML element
  2. Gladly requires that an onclick handler be bound to the same outermost HTML element
  3. The onclick handler will need to call the public Gladly API show

If the HTML custom-gladly-chat-button id is present, Gladly will do the following:

  1. decorate that HTML element with a class of gladly-show, when the button should be visible
  2. decorate that HTML element with a class of gladly-has-authenticated when a user has authenticated
  3. decorate that HTML element with a class of gladly-unread when there are unread messages

It is up to you to utilize these classes and hooks properly to render and style your own custom button as you wish.

Sample HTML

<div id="custom-gladly-chat-button" onclick="">
  <div id="gladly-not-authenticated">
    <span>LIVE CHAT</span>
  <div id="gladly-authenticated">
    <svg width="18" height="18" fill="none" viewBox="0 0 18 18">
      <path fill="#000" />
    <span class="unread-dot"></span>

Sample CSS

<style type="text/css">
    #custom-gladly-chat-button {
      visibility: hidden;

    #custom-gladly-chat-button #gladly-not-authenticated {
        visibility: hidden;

    #custom-gladly-chat-button #gladly-authenticated {
        visibility: hidden;

    #custom-gladly-chat-button.gladly-show #gladly-not-authenticated {
        visibility: visible;

    #custom-gladly-chat-button.gladly-show.gladly-has-authenticated #gladly-authenticated {
        visibility: visible;

    #custom-gladly-chat-button.gladly-show.gladly-has-authenticated #gladly-not-authenticated {
        visibility: hidden;

    #custom-gladly-chat-button .unread-dot {
        visibility: hidden;

    #custom-gladly-chat-button.gladly-unread .unread-dot {
        background-color: green;
        border-radius: 50%;
        display: inline;
        height: 8px;
        position: absolute;
        right: 12px;
        top: 8px;
        visibility: visible;
        width: 8px;


(static) Availability :string

The different availability states that exist:

  • AVAILABLE: Chat agents are ready to receive new chat messages
  • UNAVAILABLE_OFFICE_CLOSED: Chat is unavailable due to office hours
  • UNAVAILABLE_BUSY: Chat is unavailable due to high demand
  • string


(static) init(config) → {Promise}

This method initializes the Sidekick on your site using the ID specified in the config parameter. It returns a promise that will resolve when the Sidekick is ready.

Note that init must be called, and the initialization must fully complete (which is signaled when the returned promise is resolved) before calling any other api methods.

Name Type Description
config Gladly.SidekickConfig

Sidekick configuration


(static) getAvailability() → {Gladly.Availability}

This method returns the current chat Availability


(static) on(eventName, observer) → {function}

This method subscribes an observer to eventName and returns an unsubscribe function.

Name Type Description
eventName String

The name of the event to subscribe to

observer function

Observer function to be invoked when event triggers


(static) show()

This method displays the Gladly Sidekick when called.


<button onClick="">Start Chat</button>

(static) navigate()

This method is used to notify the Sidekick when your website navigates without reloading the page. Gladly will read the updated location from 'document.location.href'.

Most common use for this would be if you have a single page application and you have rules configured to control what pages the Sidekick is displayed on.



Type Definitions


Name Type Description
appId string

id specifying your own application

  • Object



When availability changes, this event emits current availability.

Type Description

Current availability