Omni-Channel Presence Integration

The following trigger enables the user availability toggles, normally updated via the Distribution Engine widget, to be controlled by changes in the Omni-Channel presence. 

  • Omni-Channel will be the master - DE changes will not be reflected in Omni-Channel.
  • Presence changes will not be reflected in the DE widget until its refreshed, which by default is every 10 minutes or on page load. It is recommended not to show the DE widget if Omni-Channel is being used to control presence.

Setup steps

  • Create a new Presence trigger in Omni-Channel
  • In Setup go to Customize > Omni-Channel > User Presences > User Presence Trigger
  • Create a new trigger E.g. DE_Omni_Trigger
  • Paste the code below
trigger DE_Omni_Trigger on UserServicePresence (after insert, after update) {   
    List<n2de.DistributionEngineGlobal.ToggleUserDTO> userDtoList = new List<n2de.DistributionEngineGlobal.ToggleUserDTO>();   
    Map<Id, ServicePresenceStatus> servicePresenceStatusMap = new Map<Id, ServicePresenceStatus>([SELECT MasterLabel FROM ServicePresenceStatus]);
    for (UserServicePresence usp : Trigger.New) {
        Id userId = usp.UserId;
        Id statusId = usp.ServicePresenceStatusId;
        boolean isOnline = !usp.IsAway;
        ServicePresenceStatus sps = servicePresenceStatusMap.get(statusId);
      String statusName = null;
        if (sps != null) {
            statusName = sps.MasterLabel;
        }      
        userDtoList.add(new n2de.DistributionEngineGlobal.ToggleUserDTO(userId, isOnline, statusName));
}
n2de.DistributionEngineGlobal.toggleUsers(userDtoList);
}

How did we do?

Salesforce Presence Integration

Contact