Skill-Based routing using Omni channel Salesforce

Admin Configuration, Lightning

Hey Awesome admin, Welcome 🙂

In this blog post, we are going to learn how to implement Skills-Based routing in Salesforce using Omni Channel. By implementing Skills-Based routing it will help our representatives to be more productive & resolve the query in a very quick way. We are going to follow the set of steps that are given below.

Enable Skill-Based Routing under Omni Channel Settings.

Create Required Skills

To assign the skills to our Agents, we need to have some skills so that we can assign them to Service Resources ( Our agents )

Create Service Channels

Service channels are the different ways by which our customers can connect with us. Like Cases, Live Agents, Messaging & etc. In our example, we will create for cases.

Create Presence Status

Presence status are the various options that an Agent can select like, Online, Out for Break, Offline, Out for Lunch, Available for Cases & etc.

  • Edit Service Resource Object Page Layout & Add Skills as Related List
  • Create custom fields into Case Object

Create an Apex Class & Create a Process Builder

Refer the below image for Process Builder

Find the code for apex class

Global class SkillsBasedRouting {
    
    @ InvocableMethod
        public static void routeUsingSkills(List<String> cases) {
            
            List<Case> caseObjects = [SELECT Id, Description, Language__c FROM Case WHERE Id in :cases];
            
            for (Case caseObj : caseObjects) {
                // Add SkillsBased PendingServiceRouting
                PendingServiceRouting psrObj = new PendingServiceRouting(
                    CapacityWeight = 1,
                    IsReadyForRouting = FALSE,
                    RoutingModel  = 'MostAvailable', //LeastAvailbale
                    RoutingPriority = 1,
                    RoutingType = 'SkillsBased',
                    ServiceChannelId = getChannelId('Case'),
                    WorkItemId = caseObj.Id
                );
                insert psrObj;
                psrObj = [select id, IsReadyForRouting from PendingServiceRouting where id = : psrObj.id];
                System.debug(' \n **** psrObj **** \n'+psrObj);
                // Now add SkillRequirement(s)
                SkillRequirement srObj = new SkillRequirement(
                    RelatedRecordId = psrObj.id,
                    SkillId = getSkillId(caseObj.Language__c)
                    //SkillLevel = 10
                );
                insert srObj;
                
                // Update PendingServiceRouting as IsReadyForRouting
                psrObj.IsReadyForRouting = TRUE;
                System.debug('\n **** psrObj *** \n'+psrObj);
                update psrObj;
            }
            return;
        }
    
    public static String getChannelId(String channelName) {
        ServiceChannel channel = [Select Id From ServiceChannel Where DeveloperName = :channelName];
        return channel.Id;
    }
    
    public static String getSkillId(String caseLanguage) {
        String skillName = 'English';
        if (caseLanguage != null) {
            skillName = caseLanguage;
        }
        
        Skill skill = [Select Id From Skill Where DeveloperName = :skillName];
        return skill.Id;
    }
}

Create Service Resource & Assign Skills to Service Agents.

To Create the Service Resource, Navigate to Service Resource Tab -> Click on New & then create a Service Resource of Type Agent.

Now, as we have added the Service Resource, Click on the Related Tab and assign skills to agent.

Assign Presence Status to the Agents profile

Go to profile -> Edit the Profile to which you wanted to assign the Presence Status. Find “Service Presence Statuses Access“, Edit & then assign the presence status from Available Service Presence Statuses to Enabled Service Presence Statuses

Test Setup

Watch the video here.

Sharing is caring 🙂 #KeepLearning #KeepSharing #AskPanther

Leave a Reply