Omni Toolkit API

lightning:omniToolkitAPI

Work with the Omni-channel toolkit.

For Use In

Lightning Experience

The lightning:omniToolkitAPI component enables a component in the utility bar for Omni-Channel to use methods like returning a list of open work items for an agent. Omni-Channel routes work to agents in the console.

This example includes a button to accept a work item that’s assigned to an agent in the Omni-Channel utility.

1<aura:component implements="flexipage:availableForAllPageTypes" access="global">
2  <lightning:omniToolkitAPI aura:id="omniToolkit" />
3  <lightning:button label="Accept" onClick="{! c.acceptWork }" />
4</aura:component>

The button in the component calls the following client-side controller.

1({
2  acceptWork: function (cmp, evt, hlp) {
3    var omniAPI = cmp.find("omniToolkit");
4    omniAPI
5      .getAgentWorks()
6      .then(function (result) {
7        var works = JSON.parse(result.works);
8        var work = works[0];
9        omniAPI
10          .acceptAgentWork({ workId: work.workId })
11          .then(function (result2) {
12            if (result2) {
13              console.log("Accepted work successfully");
14            } else {
15              console.log("Accept work failed");
16            }
17          })
18          .catch(function (error) {
19            console.log(error);
20          });
21      })
22      .catch(function (error) {
23        console.log(error);
24      });
25  },
26});

Methods 

This component supports the following methods. For more information on these methods, see the Omni-Channel Developer Guide.

acceptAgentWork({workId}): Accepts a work item that’s assigned to an agent.

  • workId (string): The ID of the work item the agent accepts.

Returns a Promise. Success resolves to true. The Promise is rejected on error.

closeAgentWork({workId}): Changes the status of a work item to Closed and removes it from the list of work items.

  • workId (string): The ID of the work item that’s closed.

Returns a Promise. Success resolves to true. The Promise is rejected on error.

declineAgentWork({workId, declineReason}): Declines a work item that’s assigned to an agent.

  • workId (string): The ID of the work item that the agent declines.
  • declineReason (string): Optional. The provided reason for why the agent declined the work request.

Returns a Promise. Success resolves to true. The Promise is rejected on error.

getAgentWorks(): Returns a list of work items that are currently assigned to an agent and open in the agent’s workspace.

Returns a Promise. Success resolves to an array of work objects. The Promise is rejected on error.

getAgentWorkload(): Retrieves an agent’s currently-assigned workload. Use this method for rerouting work to available agents.

Returns a Promise. Success resolves to configuredCapacity, currentWorkload, configuredInterruptibleCapacity and currentInterruptibleWorkload properties. The Promise is rejected on error.

getServicePresenceStatusChannels(): Retrieves the service channels that are associated with an Omni-Channel user’s current presence status.

Returns a Promise. Success resolves to an array of channel objects. The Promise is rejected on error.

getServicePresenceStatusId(): Retrieves an agent’s current presence status.

Returns a Promise. Success resolves to statusName, statusApiName and statusId properties. The Promise is rejected on error.

login({statusId}): Logs an agent into Omni-Channel with a specific presence status.

  • statusId (string): The ID of the presence status.

Returns a Promise. Success resolves to true. The Promise is rejected on error.

logout(): Logs an agent out of Omni-Channel.

Returns a Promise. Success resolves to true. The Promise is rejected on error.

setServicePresenceStatus({statusId}): Sets an agent’s presence status to a status with a particular ID. We log the user into presence if that user isn’t already logged in. This removes the need for you to make additional calls.

  • statusId (string): The ID of the presence status you want to set the agent to.

Returns a Promise. Success resolves to statusName, statusApiName, statusId properties and an array of channel objects. The Promise is rejected on error.

raiseAgentWorkFlag({workId, message}): Raises a flag for this agent work item.

  • workId (string): The ID of the work item to raise the flag on.
  • message (string): Optional. The message associated with this flag.

Returns a Promise. Success resolves to true. The Promise is rejected on error.

lowerAgentWorkFlag({workId}): Lowers a flag for this agent work item.

  • workId (string): The ID of the work item to lower the flag on.

Returns a Promise. Success resolves to true. The Promise is rejected on error.

Attributes 

NameDescriptionTypeDefaultRequired
bodyThe body of the component. In markup, this is everything in the body of the tag.Aura.Component[]

Methods 

NameDescriptionArgument NameArgument TypeArgument Description
acceptAgentWorkAccepts a work item that’s assigned to an agent.argumentsObjectArgument object with values for workId and callback.
closeAgentWorkChanges the status of a work item to Closed and removes it from the Omni-Channel widget.argumentsObjectArgument object with values for workId and callback.
declineAgentWorkDeclines a work item that’s assigned to an agent.argumentsObjectArgument object with values for workId and callback.
getAgentWorkloadReturns the agent’s currently assigned workload.argumentsObjectArgument object with value for callback.
getAgentWorksReturns a list of work items that are currently assigned to an agent and open in the agent’s workspace.argumentsObjectArgument object with value for callback.
getServicePresenceStatusChannelsReturns the service channels that are associated with an Omni-Channel user’s current presence status.argumentsObjectArgument object with value for callback.
getServicePresenceStatusIdReturns the agent’s current presence status.argumentsObjectArgument object with value for callback.
loginLogs an agent into Omni-Channel with a specific presence status.argumentsObjectArgument object with values for statusId and callback.
logoutLogs an agent out of Omni-Channel.argumentsObjectArgument object with value for callback.
lowerAgentWorkFlagLowers a flag for this agent work item.argumentsObjectArgument object with value for workId and callback.
raiseAgentWorkFlagRaises a flag for this agent work item.argumentsObjectArgument object with value for workId, message and callback.
setServicePresenceStatusSets an agent's presence status to a status with a particular Id.argumentsObjectArgument object with values for statusId and callback.