Start tracking your progress
Trailhead Home
Trailhead Home

Understand Skills-Based Routing

Learning Objectives

After completing this unit, you’ll be able to:
  • Describe common use cases for skills-based routing.
  • Describe how skills-based routing works.
  • Set up skills-based routing.

Support Customers in Their Preferred Language

Sita likes what she sees in queue-based routing, but Ursa Major recently expanded sales of solar panels to Mexico and Canada, and Sita thinks she might need more sophisticated controls. She wants Omni-Channel to route customer cases to agents who speak the customer’s preferred language and who have the right knowledge to solve the issue. For example, if a customer who speaks Spanish has a problem with their bill, then Sita wants Omni-Channel to assign the case to an agent who speaks Spanish and understands the billing system.

Sita asks Maria to investigate skills-based routing for Omni-Channel.

Get the Right Work to the Right Agent

Skills-based routing looks at the skills required to complete a work item (requested skills) and matches these to the skills that are assigned to the agent (agent’s skills). Omni-Channel routes the work to the first agent who has the required skills and who is available (that is, has the capacity to take the work item). Work items can have multiple skills, and agents can have multiple skills.

Skills-based routing uses Apex action classes to assign skills, priority, and the routing model to work items. An Apex action class might sound a bit unfamiliar, but we walk you through it later on in this unit.

When Omni-Channel receves a new work item, it looks at the required skills, the work’s priority, and the routing model (Least Active or Most Available) to determine how to route the work.

Ursa Major Solar is supporting customers in three countries who use a variety of products, and those customers have a wide range of needs. Maria confirms that skills-based routing would let Ursa Major Solar’s contact center route work to the best agent for the job—improving the quality of customer service.

Set Up Skills-Based Routing

Identify Which Skills Agents Need
To set up skills-based routing, you need a list of the skills that agents must have to resolve different work items. Talk with your contact center to find out what those are.

Maria talks to Ursa Major Solar’s support managers. She learns that the company needs agents who possess language skills, technical skills to troubleshoot solar panels, and business skills to resolve issues with orders and billing. Here’s the list she makes.

Product or Service Skills Needed
Solar panel troubleshooting Languages:
  • English, French, or Spanish
Technical skills:
  • Understand how to diagnose solar panel issues
Business skills:
  • Understand service-level agreements (SLAs)
  • Understand escalation processes
Billing problems Languages:
  • English, French, or Spanish
Technical skills:
  • Understand how to use the billing system
Business skills:
  • Understand the return policy and refund process
Orders and shipping Languages:
  • English, French, or Spanish
Technical skills:
  • Understand how to use the ordering system
  • Understand how to check shipping status
Business skills:
  • Understand how to resolve sales problems
Maria wants to set up skills-based routing with skills for English, French, and Spanish; for hardware technical support and software technical support; and for orders and billing. Here’s what she does.
  1. From Service Setup, enter Omni-Channel in the Quick Find box, then select Omni-Channel Settings.
  2. Select Enable Skills-Based Routing, then click Save.
  3. Enter Omni-Channel in the Quick Find box, then select Skills.
  4. Click New.
  5. Enter a name for the skill.
    1. Maria creates a skill called Spanish.
  6. Optionally, enter a description of the skill.
  7. Skip the Assign Users and Assign Profiles sections. Instead, you add these skills in Service Resources in a minute.
  8. Click Save.
  9. Maria repeats steps 2–7 to define more skills from her planning list.
  10. She then adds Skills as a related list to the newly enabled Service Resource object.
    1. From Setup, select Object Manager.
    2. Enter Service Resource in the Quick Find box and select Service Resource.
    3. Select Page Layouts then select Service Resource Layout to edit it.
    4. Click Related Lists and drag Skills onto the page layout.
    5. Click Save.
Create Service Resources for Agents
Service resources represent individual agents. Maria creates a service resource for each agent.
  1. From the App Launcher search for Service Resources and select Service Resources.
  2. Click New.
  3. For Name, enter the name of the agent.
  4. Select the Active checkbox. A service resource must be active to receive work items.
  5. For User, use the lookup icon to select the agent.
  6. For Resource Type, select Agent.
  7. Click Save.
Assign Skills to Agents
Assign skills to your agents to track their areas of experience and their level of proficiency for each skill. Here’s how Maria assigns skills to Ursa Major Solar’s agents.
  1. From the App Launcher search for Service Resources and select Service Resources.
  2. Select the service resource that you just created.
  3. From the Skills related list, click New.
  4. Select a skill. You can optionally enter a skill level 0–10.
  5. Enter a start date, and if needed, an end date. For example, if an agent must be recertified in a particular skill every 6 months, enter an end date that’s 6 months later than the start date.
  6. Click Save.
  7. The service resource’s skill now appears in their Skills related list.
Create an Apex Action Class to Assign Skills to Work Items
Skills-based routing uses Apex action classes to assign skills, priority, and the routing model to work items. You create an Apex action class and then create a workflow that calls the Apex class. We provide some example Apex code below that you can copy and paste into the setup.
Maria writes an Apex action class that specifies the language required for a work item, sets the priority to 1, and sets the routing model to Most Available.
  1. From Setup, enter Apex in the Quick Find box, then select Apex Classes.
  2. Click New.
  3. In the Apex Class field, enter the Apex code similar to what’s shown in the example.
  4. Click Save.
  5. Use this Apex class when you create a workflow for skills-based routing.
Global class SkillsBasedRouting {
      @ InvocableMethod
      public static void routeUsingSkills(List<String> cases) {
           List<Case> caseObjects = [SELECT Id, Description FROM Case WHERE Id in :cases];


     for (Case caseObj : caseObjects) {
         // Add SkillsBased PendingServiceRouting
         PendingServiceRouting psrObj = new PendingServiceRouting(
             CapacityWeight = 1,
             IsReadyForRouting = FALSE,
             RoutingModel  = 'MostAvailable',
             RoutingPriority = 1,
             RoutingType = 'SkillsBased',
             ServiceChannelId = getChannelId('Case'),
             WorkItemId = caseObj.Id
             );
         insert psrObj;
         psrObj = [select id, IsReadyForRouting from PendingServiceRouting where id = : psrObj.id];
         
         // Now add SkillRequirement(s)
         SkillRequirement srObj = new SkillRequirement(
             RelatedRecordId = psrObj.id,
             SkillId = getSkillId(caseObj.Description),
             SkillLevel = 5
             );
         insert srObj;
         
         // Update PendingServiceRouting as IsReadyForRouting
         psrObj.IsReadyForRouting = TRUE;
         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 caseDescription) {
      String skillName = 'English';
      if (caseDescription != null) {
          if (caseDescription.contains('Spanish')) {
              skillName = 'Spanish';
          } else if (caseDescription.contains('French')) {
              skillName = 'French';
          }
      }
      
      Skill skill = [Select Id From Skill Where DeveloperName = :skillName];
      return skill.Id;
  }
}
Create a Process
Next, Maria creates a process that tells Omni-Channel to route a new case using skills-based routing, so that it assigns cases to the right agent for the job.
  1. From Setup, enter Process Builder in the Quick Find box, then select Process Builder.
  2. Click New.
  3. In the New Process modal window, complete the following fields:
    1. For Process Name, specify the name for this process. Maria enters Skills-based routing.
    2. The API Name is automatically populated.
    3. For Description, optionally describe what this process does.
    4. For This process starts when, select A record changes.
    5. Click Save.
  4. On the next page, click + Add Object and select Case.
  5. For Start the process, select Only when a record is created.
  6. Click Save. In the diagram, you can see that the Add Object box is now Case.
  7. Click the + Add Criteria diamond.
  8. Enter a Criteria Name. Maria enters No criteria.
  9. For Criteria for Executing Actions, select No criteria--just execute the actions!
  10. Click Save.
  11. In the Immediate Actions box, click + Add Action.
  12. For Action Type, select Apex.
  13. For Action Name, enter the name of your action. Maria enters Skills-based routing.
  14. For Apex Class, select the name of the Apex class that you created. Maria selects SkillsBasedRouting.
  15. For Set Apex Variables, click + Add Row and set the following parameters:
    1. For Field, select cases.
    2. For Type, select Field Reference.
    3. For Value, use the lookup icon to select Case ID and click Choose.
  16. Click Save. The activation window opens.
  17. To activate this process, click Activate and then Confirm. The activation window closes. When a case is created, it triggers this workflow and routes the case based on skills.
retargeting