Avaya Client SDK

< Back to Package Overview

Initializing the Agent Service

This article discusses how to initialize the Agent Service within your website.

Creating a Client

The central class of the Avaya Co-Browsing Services is AvayaCoBrowseClientServices. Agent website using the Avaya Client SDK has its own instance of AvayaCoBrowseClientServices and maintains a reference to this object in order to start an AgentCobrowse and access features within the 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 that you define within CoBrowseConfiguration are 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;

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

Creation of the Client object

Create an AvayaCoBrowseClientServices instance.

    var _coBrowseAgentClientService = new AvayaCoBrowseClientServices(_cbconfig);

    // To register logger
    _coBrowseAgentClientService.registerLogger(window.console);

Create instance

Create an instance

    _cbinstance = _coBrowseAgentClientService.createAgentCobrowse(_cbconfig);

Initialize Service context name

Service context name for customer

    _cbinstance = _coBrowseCustomerClientService.initAgentServiceContext(_serviceContext);

Start Agent Service

To render the Customer webpage on IFrame, You must provide IFrameId. After setting the IFrameId, Start the Agent service.

    // To set IFrame which renders customer webpage
    _cbinstance.setIFrame(_iframeId);
    _cbinstance.start();

Register Callbacks

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

Register OnPause Callback

addOnPauseCallback is called to report that the Customer has paused the Avaya Co-Browsing session.

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

Register OnResume Callback

addOnResumeCallback is called to report that the Customer has resume the Avaya Co-Browsing session.

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

Register OnControlGrant Callback

addOnControlGrantCallback is called to report that the Customer has granted the Avaya Co-Browsing session control.

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

Register OnControlDenial Callback

addOnControlDenialCallback is called to report that the Customer has denied the Avaya Co-Browsing session control.

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

Register OnControlRevoke Callback

addOnControlRevokeCallback is called to report that the Customer has revoked the Avaya Co-Browsing session control.

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

Register OnSessionClose Callback

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

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

Register OnCustomerJoin Callback

addOnCustomerJoinCallback is called to report that the Customer has joined the Avaya Co-Browsing session.

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

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 agent
    });

Register OnConnection Callback

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

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

Register OnInActivityTimeOutOccurred Callback

addOnInActivityTimeOutOccurredCallback is called to report that the Agent is inactive during an active Avaya Co-Browsing session.

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

Register OnStopInActivityTime Callback

addOnStopInActivityTimeOutCallback is called to report that the Agent has become active during an active Avaya Co-Browsing session.

    _cbinstance.addOnStopInActivityTimeOutCallback(function (message) {
        // Called to report the agent has become active during 
        // active co-browsing session
        // Add code here to notify agent
    });

Reinitializing a Service

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