Avaya Client SDK

< Back to Package Overview

Initializing the Customer Service

This article discusses how to initialize the Customer service within your website.

Creating a Client

The central class of the SharingServices Package is AvayaCoBrowseClientServices. Customer website using the SharingServices Package has its own instance of AvayaCoBrowseClientServices and maintains a reference to this object in order to start an CustomerCobrowse and access features within the Avaya Co-Browsing SDK.

Client Configuration

As part of the process to create your client instance, you must create a CoBrowseConfiguration object that defines your website. The attributes you define within CoBrowseConfiguration will be used to interact with Breeze server over the network:

    //Set the service context name, supported names are "services,avservice"
    //Default name is "services"    
    _serviceContext = "avservice";
    _cbconfig = new AvayaCoBrowseClientServices.Config.CoBrowseConfiguration();
    //Set FQDN/hostname of the breeze server
    _cbconfig.serverInfo.hostName = "localhost";
    //Set the port number to access breeze server 
    _cbconfig.serverInfo.port = '8443';
    //Set to true for secure communication. Default value is false 
    _cbconfig.serverInfo.isSecure = true;
    //To enable co-browsing. Default value is false
    _cbconfig.enabled = true;
    //To allow customer's information persist in the CoBrowse Database. Default value is 'true' 
    //Setting it to 'false' restricts CoBrowse to persist customer's information in Database  
    _cbconfig.consent = true;

Note: For more information on service configuration, see Configuring the SDK.

Creation of the Client object

Create a AvayaCoBrowseClientServices instance

    var _coBrowseCustomerClientService = new AvayaCoBrowseClientServices(_cbconfig);
    // To register logger
    _coBrowseCustomerClientService.registerLogger(window.console);

Initialize Service context name

Service context name for customer

    _cbinstance = _coBrowseCustomerClientService.initCustServiceContext(_serviceContext);

Start Customer Service

Start the customer service

    _cbinstance = _coBrowseCustomerClientService.createCustomerCobrowse(_cbconfig);
    _cbinstance.start();

Register Callbacks

Callbacks are used to handle events that occur during the active Avaya Co-Browsing session.

Register OnConnectionReset Callback

addOnConnectionResetCallback is called to report that the network connection has been re-established.

    _cbinstance.addOnConnectionResetCallback(function (evt) {
        // Called to report the network connection has been 
        // re-established
        // Add code here to notify customer
    });

Register OnConnectionFailure Callback

addOnConnectionFailureCallback is called to report that the network connection is failed.

    _cbinstance.addOnConnectionFailureCallback(function (evt) {
        // Called to report the network connection is 
        // failed
        // Add code here to notify customer
    });

Register OnConnection Callback

addOnConnectionCallback is called to report that the network connection has been established.

   _cbinstance.addOnConnectionCallback(function (evt) {
        // Called to report the network connection has been 
        // established
        // Add code here to notify customer
    });

Register OnSessionClose Callback

addOnSessionCloseCallback is called to report that the Agent has closed Avaya Co-Browsing session.

    _cbinstance.addOnSessionCloseCallback(function (evt) {
        // Called to report the agent has 
        // closed co-browsing session
        // Add code here to notify customer
    });

Register OnControlRequest Callback

addOnControlRequestCallback is called to report that the Agent has requested Avaya Co-Browsing session control.

    _cbinstance.addOnControlRequestCallback(function (evt) {
        // Called to report the agent has 
        // requested co-browsing session control
        // Add code here to notify customer
    });

Register OnControlRelease Callback

addOnControlReleaseCallback is called to report that the Agent has released Avaya Co-Browsing session control.

    _cbinstance.addOnControlReleaseCallback(function (evt) {
        // Called to report the agent has 
        // released co-browsing session control
        // Add code here to notify customer
    });

Register OnCancelRequestControl Callback

addOnCancelRequestControlCallback is called to report that the Agent has canceled request for Avaya Co-Browsing session control.

    _cbinstance.addOnCancelRequestControlCallback(function (evt) {
        // Called to report the agent has 
        // canceled request for co-browsing session control
        // Add code here to notify customer
    });

Register OnfireInactivity Callback

addOnfireInactivityCallback is called to report that the Customer is inactive during active Avaya Co-Browsing session.

    _cbinstance.addOnfireInactivityCallback(function (msg) {
        // Called to report the customer is inactive during 
        // active co-browsing session
        // Add code here to notify customer
    });

Register OnStopInactivity Callback

addOnStopInactivityTimerCallback is called to report that the Customer is active during active Avaya Co-Browsing session.

    _cbinstance.addOnStopInactivityTimerCallback(function (msg) {
        // Called to report the customer is active during 
        // active co-browsing session
        // Add code here to notify customer
    });

Register OnAgentJoin Callback

addOnAgentJoinCallback is called to report that the Agent has joined Avaya Co-Browsing session control.

    _cbinstance.addOnAgentJoinCallback(function (evt) {
        // Called to report the agent has 
        // joined co-browsing session control
        // Add code here to notify customer
    });

Register OnUpdateHtmlBodyLink Callback

addOnUpdateHtmlBodyLinkCallback is called to execute the custom logic to process the href for link tag within the body.

     var replaceContextNameFromPath = "/web/";
    _cbinstance.addOnUpdateHtmlBodyLinkCallback(function (evt) {
        // Called to execute the custom logic to process the link tag
        //example: replaceContextNameFromPath the required absolute path for the resources
          if (href.indexOf("/") === 0 || href.indexOf("http") !== 0) {
            data.href = href.replace(replaceContextNameFromPath, "/");
        }
    });

Register OnUpdateHtmlBodyImage Callback

addOnUpdateHtmlBodyImageCallback is called to execute the custom logic to process the src for image tag within the body.

     var replaceContextNameFromPath = "/web/";
    _cbinstance.addOnUpdateHtmlBodyImageCallback(function (data) {
        // Called to execute the custom logic to process the image tag present within the page body
        //example: replaceContextNameFromPath the required absolute path for the resources 
        if (src.indexOf("/") === 0 || src.indexOf("http") !== 0) {
           data.src = src.replace(replaceContextNameFromPath,"/");
        }
    });

Register OnOnUpdateHtmlHead Callback

addOnUpdateHtmlHeadCallback is called to execute the custom logic to process the href for link tag present in the html head.

     var replaceContextNameFromPath = "/web/";
    _cbinstance.addOnUpdateHtmlHeadCallback(function (data) {
        // Called to execute the custom logic to process the href for link tag present in the html head
        //example: replaceContextNameFromPath the required absolute path for the resources
        if (href.indexOf("/") === 0 || href.indexOf("http") !== 0) {
            data.href = href.replace(replaceContextNameFromPath, "/");
        }
    });

Reinitializing a Service

Support to reinitialize Customer service feature is planned for the future release.