^
^
JavaScript Customer Interaction Services Package
Table of Contents

< Back to Package Overview

Tutorials

Event Listener Tutorial

Here is a simple example demonstrating the use of Agent methods and event listeners.

var config = {
    uacConfiguration: new AvayaCustomerServices.Config.UACConfiguration({
        enabled: true,
        clientInfo: {
            id: 'sampleApp'
        },
        serverInfo: {
            apiUrl: 'https://BREEZE-FQDN/services/UnifiedAgentController/UACAPI'
        },
        notificationInfo: {
            broadcastUrl: 'https://BREEZE-FQDN/services/Broadcast-UnifiedAgentController/broadcast',
            fallbackTransport: 'websocket'
        },  
        authenticationInfo: { 
            enabled: true, 
            tokens: ['Authorization'] 
        }
    })
};

var client = new AvayaCustomerServices(config);
var clientSession = client.createClientSession();

// Set token to SDk token store (token retrieval not shown)
clientSession.setToken(token);

var agent = clientSession.createAgent();

agent.addOnActivatedCallback(function (agent) {
  console.log('Agent Client Session has been successfully activated');
});

agent.addOnDeactivatedCallback(function (agent) {
  console.log('Agent Client Session has been successfully deactivated');
});

agent.addOnStateReadyCallback(function (state) {
  console.log('Agent State has been successfully set to Ready');
});

agent.addOnStateNotReadyCallback(function (state) {
  console.log('Agent State has been successfully set to Not Ready');
});

agent.addOnStateLoggedOutCallback(function (state) {
  console.log('Agent has been successfully logged out');

agent.addOnSessionInitialisedCallback(function () {
  console.log('Notification session has been initialized');
});

$('#agent-activate').on('click', function () {
    var username = $('#activate').val();
    agent.activate(username);
});

$('#agent-login').on('click', function () {
    agent.login();
});

$('#agent-goready').on('click', function () {
    agent.goReady();
});

$('#agent-gonotready').on('click', function () {
    agent.goNotReady();
});

$('#agent-logout').on('click', function () {
    agent.logout();
});

$('#agent-deactivate').on('click', function () {
    agent.deactivate();
});
Feedback

Your feedback has been successfully submitted.

There was a problem submitting your feedback. Please contact your product support representative.

Page Feedback