Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejs
$(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
(in this example password is not required)        //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:

...