Home

Livesupp PageAPI documentation

Click for detailed documentation

How to get the PageAPI object

Our widget fires a LIVESUPP_LOADED event on the window object after the widget has finished loading and is ready to be used. The details property of the event object contains a property api representing the PageAPI object.

window.addEventListener('LIVESUPP_LOADED', async event => {
   const lsAPI = event.detail.api // we will refer to the PageAPI object as lsAPI
   // now you can use the api
})

PageAPI features

PageAPI.renderCobrowsingCode - Render a cobrowsing code into a custom element

PageAPI.disable - Hide Livesupp and disconnect customer from backend

PageAPI.enable - Establish connection to backend and show Livesupp again after using PageAPI.disable()

PageAPI.enable() cannot be used before PageAPI.disable()

/*
   element - the HTMLElement you wish to render the cobrowsing code component into

   returns a Promise that resolves after the element is rendered
*/

await lsAPI.renderCobrowsingCode({
   element: document.getElementById('target-element'),
})

PageAPI.on - Listens to an event

Listenable Events:

cobrowsing.started

lsAPI.on('cobrowsing.started', () => {
   /*
      This function gets called when cobrowsing starts.
   */
})

PageAPI.getResolvingOperator() - retuns id of operator the customer is assigned to

/*
   Note: If the customer is not assigned to any operator, the returned value is null.
*/

lsAPI.getResolvingOperator()