^
^

< Back to Package Overview

Work API

Overview

Retrieve an instance of the Work API from the Client Session object using:

var work = clientSession.getWork(); 

Retrieve Work Requests

Retrieve the workRequests Collection from the Work object using:

var workRequests = work.getWorkRequests();  

Retrieve All Interactions

Retrieve the Interactions Collection from the Work object using:

var interactions = work.getInteractions();  

The WorkRequest object

WorkRequest Methods

Get Interactions

A Work Request groups all interactions carried out with a particular Customer. To get a list of Interactions belonging to a Work Request, the following syntax is used.

var interactions = workRequest.getInteractions();

The Interaction object

Interaction Methods

Start Interaction

An Interaction is started from the Work API.

To start a 'Voice' Interaction to 'destination', the following syntax is used

var voiceInteraction = work.createInteraction('VOICE', 'destination');

To start an 'Email' Interaction to 'destination', the following syntax is used

var voiceInteraction = work.createInteraction('EMAIL', 'destination');

Listening for Interaction Events

An event listener can be attached to "listen" to specific events on the interaction object. There are 2 types of events - general and specific events.

You can use general events to find out when an interaction has been updated, for example, but aren't interested in what exactly has changed. Examples include:

//these events are attached to the Work object
work.addOnInteractionCreatedCallback(callback);
work.addOnInteractionDeletedCallback(callback);

//this event is attached to the interaction object itself
interaction.addOnInteractionUpdatedCallback(callback)

If you wish to be notified when a specific event has happened, you can listen to more granular events. Examples include:

interaction.addOnInteractionActiveCallback(callback);
interaction.addOnInteractionPassiveCallback(callback);
interaction.addOnInteractionHeldCallback(callback);
interaction.addOnInteractionACWCallback(callback);
interaction.addOnInteractionEndedCallback(callback);
interaction.addOnInteractionMediaAddedCallback(callback);
interaction.addOnInteractionContextAddedCallback(callback);
interaction.addOnInteractionContextRemovedCallback(callback);

// Event listener called on interaction media added
interaction.addOnInteractionMediaAddedCallback(callback);

// Event listener called on interaction context added
interaction.addOnInteractionContextAddedCallback(callback);
interaction.addOnInteractionContextRemovedCallback(callback);

Listening for Created Interaction Event

An event listener can be attached to "listen" for a created interaction event using the following syntax.

work.addOnInteractionCreatedCallback(function (workRequest, interaction) {
    console.log('A new interaction has been created');
});

Listening for Deleted Interaction Event

An event listener can be attached to "listen" for a deleted interaction event using the following syntax.

work.addOnInteractionDeletedCallback(function (workRequest, interaction) {
    console.log('Outbound interaction successfully created');
});

Interaction Control

Accept Interaction

Accept an interaction by using the following syntax.

interaction.accept();

End Interaction

End an interaction by using the following syntax.

interaction.end();

Hold Interaction

Put and interaction on hold by using the following syntax.

interaction.hold();

Unhold Interaction

Resume the interaction by using the following syntax.

interaction.unhold();

Send DTMF

Send a DTMF digit while on interaction by using the following syntax.

interaction.sendDTMF(digit);

Consult / Complete Transfer Interaction

To consult on the interaction with a remoteAddress by using the following syntax.

interaction.consult(remoteAddress);

To complete a consult interaction as a Conference

interaction.completeConference();

To complete a consult interaction as a Transfer

interaction.completeTransfer();

Single Step Transfer an Interaction

Transfer an interaction (without first going to a consult) by using the following syntax.

interaction.singleStepTransfer(remoteAddress);

Single Step Transfer an Interaction to a Service

Transfer an interaction to a Service (without first going to a consult) by using the following syntax.

interaction.singleStepTransferToService(serviceId);

Work Codes

Work Codes are a subset of Reason Codes of type "WORK"

Get All Work Codes

To retrieve a list of Work Codes, they must be fetched from the SDK using the following syntax.

var workCodes = clientSession.getReasonCodes().findAllByType('WORK');

This will return an array of Reason Code Objects

Set / Get Work Code

To Set a Work Code on an interaction, use the following syntax.

interaction.setWorkCode(workCodes[0].id);   

To retrieve an already set Work Code on an interaction, use the following syntax.

var workCode = interaction.getWorkCode();   

Disposition Codes

Disposition Codes are a subset of Reason Codes of type "DISPOSITION"

Get All Disposition Codes

To retrieve a list of Disposition Codes, they must be fetched from the SDK using the following syntax.

var dispositionCodes = clientSession.getReasonCodes().findAllByType('DISPOSITION');

This will return an array of Reason Code Objects

Set / Get Disposition Code

To Set a Disposition Code on an interaction, use the following syntax.

interaction.setDispositionCode(dispositionCodes[0].id); 

To retrieve an already set Disposition Code on an interaction, use the following syntax.

var dispositionCode = interaction.getDispositionCode(); 

The InteractionMedia object

Listening for InteractionMedia Events

The 'onMediaAdded' callback will fire when an InteractionMedia object has been added to an interaction (onMediaAdded is a callback that is attached to an interaction object).


function onMediaAdded(interaction, message) {
    var media = interaction.getInteractionMedia();

    media.addMessageReceivedCallback(callback);
    media.addOnAttachmentAddedCallback(callback);
    media.addOnPagePushUrlCallback(callback);
    media.addOnIsTypingCallback(callback);
    media.addOnConnectedCallback(callback);
    media.addOnDisconnectedCallback(callback);

    media.addOnFileTransferredCallback(callback);
    media.addOnCustomerDownloadInitiatedCallback(callback);
    media.addOnCustomerDownloadCompleteCallback(callback);
  }

InteractionMedia Methods

Send Message

To send a Chat / SMS / Social message use the following syntax.

interactionMedia.send(message, sensitivity);

Send Email

To send an Email by use the following syntax.

interactionMedia.sendEmail(data);

Send PagePush Url

To send a page push URL use the following syntax.

interactionMedia.sendPagePushUrl(url);

Send CoBrowse Session Key

To send a CoBrowse session key use the following syntax.

interactionMedia.sendCoBrowseSessionKey(key);

Report Typing

To report that the Agent has started typing use the following syntax.

interactionMedia.reportTyping(sensitivity);
Feedback

Your feedback has been successfully submitted.

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

Page Feedback