...
In the following example we will use the jQuery $
support library to dynamically load the SDK.
Once loaded, the CTLive SDK is accessed 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 CTLive SDK
return LIVECHATSDK.SDK.init("https://mywebsite.com/livechat/:domain/")
})
.then(function() {
// Login the agent to CTLive
//jwt is optional.
//If not provided a redirect towards IdentityProvider is requested
return LIVECHATSDK.LIVECHAT.login(jwt);
})
.then(function(){
return LIVECHATSDK.LIVECHAT.init({
"nickname": "Agent1",
"isAgent": true,
"id": "USER_AGENT1",
"channel": "web"
})
})
.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