Omni-Channel Presence Integration

The following trigger enables the Distribution Engine widget toggle 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 reflected in the DE widget until its refreshed. Its 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?

Invalid Email trigger

Contact