Skills-Based Routing Using Apex in Salesforce Omni-Channel

We had set up Salesforce Omni-Channel for one of our clients to route support cases using queue-based routing. Initially, we used flows to assign skills based on fixed values, such as product or language.

Later, the client requested a more dynamic routing setup, where the case should be assigned to agents based on multiple conditions like Customer Category, Language, and Case issue type.

For example, a case from a customer for a hardware issue in the German language should only go to an agent who meets all those criteria.

To meet this requirement, we reconfigured the routing using Apex instead of flows. In this Salesforce tutorial, I will explain how you can set up skills-based routing in Salesforce Omni Channel using Apex.

Skills-Based Routing Using Apex in Salesforce Omni-Channel

In the below example, we will create an Apex Class that will contain the method to assign cases to the agents based on their skills. We will set up skills-based routing from scratch in the steps below.

The prerequisite is that you should have enabled and set up Omni-Channel in your Salesforce org.

After this, you can proceed with the steps below to set up skills-based routing in Salesforce Omni Channel using Apex. We will cover the following points in this skill routing setup in Omni-Channel:

  • Enable Skill-Based Routing
  • Create a Service Channel
  • Create Skills
  • Create Service Resource for Agents
  • Create an Apex Class to Assign Work Based on Agent’s Skill
  • Create a Record-Trigger Flow to Call the Apex Class

Enable Skill-Based Routing in Salesforce Omni-Channel

The first step for skill-based routing is to enable it from the Omni-Channel settings.

To enable skills-based routing, navigate to Setup -> Omni-Channel Settings -> select the checkbox Enable Skills-Based and Direct-to-Agent Routing and click Save.

Skills based Routing in Omni-Channel using Apex

With this, the skills-based routing is enabled in the Omni-Channel.

Create a Service Channel

In this step, we will create a service channel. It allows us to manage sources of work and their priori