...
In the following example we will use the jQuery $
support library to dynamically load the SDK. Once loaded the CTLive SDK is accessed through the global variable LIVECHATSDK
.
Code Block | ||
---|---|---|
| ||
$(document).ready( function() { jQuery$.getScript("https://mywebsite.com/livechat/lib/livechatagentsdk.js", function () { LIVECHATSDK.SDK.Init(window.location.origin + ""https://mywebsite.com/livechat/").then( function() { console.log("[CTLIVE] // CTLive Agent's SDK library loaded"); // Library Initialization... LIVECHATSDK.LIVECHAT.init( { "nickname": "Agent1", "isAgent": true, "id": "USER_AGENT1", "channel": "web" } ).then( function() { console.log("[CTLIVE]// Initialization completed successfully"); }, function() { console.error("[CTLIVE]// Initialization failed"); } ); } ).catch( function(err) { console.error(err); } ); } ); } ); |
...