...
Once loaded, the CTLive SDK is accessible through the global variable LIVECHATSDK
.
The library instance must be initialized by specifying some basic parameters such as the CTLive server domain, the engagement channel (web), the user ID and the nickname.
Code Block | ||
---|---|---|
| ||
$(document).ready( function() { $.getScript("https://mywebsite.com/livechat/:domain/lib/livechatagentsdk.js",) .then(function() { // Initialize the functionCTLive ()SDK { return LIVECHATSDK.SDK.Initinit("https://mywebsite.com/livechat/:domain/").then( }) .then(function() { // Login the agent to CTLive // CTLive Agent's SDK library loaded //jwt is optional. //If Library Initialization... not provided a redirect towards IdentityProvider is requested return LIVECHATSDK.LIVECHAT.initlogin(jwt); }) .then(function(){ return LIVECHATSDK.LIVECHAT.init({ "nickname": "Agent1", "isAgent": true, "id": "USER_AGENT1", "channel": "web" } ).then( function() { // Initialization completed successfully }, function() { // Initialization failed } ); } ).catch( function(err) { console.error(err); } ); } ); } ); ); |
CTLive SDK needs to be initialized specifying some parameters:
domain: unique domain identifier
nickname: a friendly id that identifies the user. This string will be used in the chat transcript.
isAgent: a true/false value that identifies the user as a call center agent
id: unique user identifier
channel:
web
is the default value, otherwisewhatsapp
identify an engagement from the WhatsApp mobile application