Skip to main content

Javascript SDK

SDK implementation

To use the SDK, insert the code below on your site.

(function () {
eKonsilio =
window.eKonsilio ||
function () {
(eKonsilio.q = eKonsilio.q || []).push(arguments);
};
var s = document.createElement("script");
s.type = "text/javascript";
s.async = true;
s.src = "https://livechat.ekonsilio.io/sdk.js";
document.getElementsByTagName("body")[0].append(s);
})();

Using the SDK

This SDK allows you to perform the following actions:

  • Perform actions (retrieve service status, open window, close window).
  • Listen to events (change service status, open/close window by viewer, start conversation by visitor).

To use the SDK, you need to call it the eKonsilio function.

It can be used with different parameters:

  • For an action :
    1. action
    2. callback
  • For an event :
    1. on
    2. event
    3. callback

Actions

status : Service status

The callback function returns an object with the following properties:

  • online : boolean indicating whether the service is online or offline
  • operator : object
    • name : string - name of the advisor
    • title : string - advisor's title
    • picture : string - photo of the advisor
eKonsilio("status", ({online, operator}) => {
console.log(online, operator);
});

maxmize : Opens the window

eKonsilio("maxmize");

minimize : Closes the window​

eKonsilio("minimize");

isMaximized : Window opening status

The callback function returns a Boolean indicating whether the window is open or not.

eKonsilio("isMaximized", (isMaximized) => {
console.log(isMaximized);
});

data : Associate information with a conversation

eKonsilio("data", {"custom_param_1": "data1", "custom_param_2": "data2"});

Events

service:status : Change in service status

The callback function returns an object with the following properties:

  • online : boolean indicating whether the service is online or offline
  • operator : object
    • name : string - name of the advisor
    • title : string - advisor's title
    • picture : string - photo of the advisor
eKonsilio("on", "service:status", (data) => {
console.log("[eKonsilio SDK]", "service:status", data);
});

window:maximized : Open the window

The callback function can return the conversation identifier as the first parameter if a conversation has been started by the user, otherwise the first parameter of the function will be null.

eKonsilio("on", "window:maximized", (data) =>
console.log("[eKonsilio SDK]", "window:maximized", data)
);

window:minimized : Closes the window

The callback function can return the conversation identifier as the first parameter if a conversation has been started by the user, otherwise the first parameter of the function will be null.

eKonsilio("on", "window:minimized", (data) =>
console.log("[eKonsilio SDK]", "window:minimized", data)
);

conversation:new : New conversation

The callback function returns the conversation identifier as the first parameter.

eKonsilio("on", "conversation:new", (data) =>
console.log("[eKonsilio SDK]", "conversation:new", data)
);