Omni-Channel: Skill Based Routing Part-3

Looking for Salesforce Training & HandsOn Projects?

Trailblazer Profile | LinkedIn | Salesforce Blog | Facebook | Youtube Channel | WhatsApp Community

Having mastered service resource creation, skill assignment, and agent presence (Demo Stages 5-7) in the previous article, we're ready to tackle the next critical steps (Demo Stages 8-9). This article will guide you through building a custom Case Routing Engine with Apex code. This engine will be intelligently triggered by a Case record change event, managed through your choice of Flow or Process Builder, to ensure seamless case routing based on agent skills and availability.

Custom Routing Engine

Why a Custom Routing Engine?

There can be several reasons to build a custom solution:

  • Complex Routing Rules: Standard Omni-Channel routing might not accommodate intricate routing logic based on factors beyond simple skills and availability.
  • Integration with External Systems: Your custom engine could integrate with external data sources containing real-time agent information or skill updates.
  • Customization Needs: You might require a more granular level of control over the routing process to fit your unique business needs.

Stages of Custom Routing Engine

  • Case Analysis: Upon case creation or update, Apex code will analyze the case details. This might involve extracting keywords, identifying the issue category, or referencing custom fields.
  • Skill Matching: Based on the case analysis, the code will determine the required skills for resolving the case.
  • Agent Availability Check: The engine will query available Service Agents, considering factors like their skill sets, workload, and current status (online, offline, etc.).
  • Agent Selection: Using a defined algorithm (e.g., least workload, first available with required skills), the engine selects the most suitable agent.
  • Case Assignment: The case is assigned to the chosen agent through the Salesforce API, ensuring proper ownership and visibility within the Service Console.

Demo (Stage-8): Routing Work Items with Apex

1.      AssignCasesToAgent 

  • Query Case Records: Utilize the Salesforce Object Query Language (SOQL) to retrieve relevant case data. This might involve filtering cases based on specific criteria like urgency, subject, or product category. Extracted case details can be used to determine the required skill set for resolving the case. 
  • Query Available Skills: Access the "Skill" object within Salesforce to identify the skills currently available amongst your Service Agents. You can leverage SOQL to retrieve information on active skills and their associated agents. 
  • Query Default Skill: Define a default skill to handle cases where a specific skill set cannot be identified from the case analysis.This ensures cases are never left unassigned, even if a perfect skill match isn't available. The default skill could represent general customer service expertise or a broader category encompassing multiple related skills.

2.      CreatePendingServiceConfig

  • getPendingServiceRouting: This method retrieves information about a pending service routing record. This record represents a case or other work item waiting for agent assignment. The retrieved information includes details like the work item itself, its current routing status, and any existing routing configurations.
  • getSkills: This custom logic (not a built-in method) determines the skills required to resolve the pending service (case). This might involve analyzing case details, extracting keywords, or referencing custom fields. The output of this logic is a list of relevant skill identifiers.
  • SkillRequirement Object: The SkillRequirement class in Salesforce Omni-Channel is a standard object designed to represent the skills needed to complete a specific task. It plays a crucial role in skill-based routing within the platform. A new record in this object is created, linking the specific case to the required skill set.
  • PendingServiceRouting.IsReadyForRouting: It is a boolean field on the PendingServiceRouting object within Salesforce Omni-Channel. It acts as a flag indicating whether a specific work item (case, chat, etc.) is prepared for agent assignment through the Omni-Channel routing engine. 
    • If True, then the work item's routing configuration is complete and ready for agent selection based on defined criteria.
    • If False, then the work item's routing configuration is still being defined or requires further processing before agent assignment can occur. The Omni-Channel engine considers only work items with IsReadyForRouting set to True when searching for available agents.

GetPendingServiceRouting


An instance of the PendingServiceRouting class (or equivalent depending on your platform) is created. This class is a core element used to configure how a work item (case) is routed through the Omni-Channel system. It acts as a container for information about the work item and its routing requirements.

Key Properties of PendingServiceRouting Class

  • WorkItemId: Reference ID of the work item (e.g., case ID).
  • Subject: Subject of the work item.
  • Channel: Channel through which the work item originated (e.g., voice, chat, email).
  • RoutingType: Defines the type of routing logic to be applied (e.g., Skills-Based Routing, Queue-Based Routing - specific options might vary).
  • RoutingPriority: The priority level assigned to the work item, influencing agent selection.
  • CapacityWeight: (Optional) A weight assigned to the work item, potentially impacting agent selection based on workload.
  • ServiceChannelId: ID of the designated service channel for handling the work item (e.g., specific queue or agent group).
  • RoutingModel: (Optional) Defines the specific routing algorithm used within the chosen routing type (e.g., Most Available, Round Robin - specific options might vary).
  • IsReadyForRouting: Flag indicating whether the routing configuration for this work item is complete (typically set to True after defining skills or other routing criteria).

GetChannelId

In Omni-Channel, service channels are configured to define how work items are routed to agents. This class represents a communication channel through which customers can interact with your organization.

Examples of service channels include:

  • Voice calls
  • Chat sessions
  • Email messages
  • Social media interactions 

Properties associated with a service channel might include:

  • Channel Type: Identifies the specific communication channel (e.g., Voice, Email).
  • Routing Configuration: Defines rules for assigning work items received through this channel to appropriate agents. This configuration could involve factors like agent skills, availability, and workload.
  • Presence Statuses: Specifies the different availability statuses agents can set for this channel (e.g., Online, Offline, Busy).

Build a query to retrieve a list of Service Channels available with in your Organization.

GetSkills

This method is used for identifying relevant skills based on case details within a custom Salesforce Omni-Channel routing solution.

Case Description Analysis

  • Extract relevant information from the case description. This might involve:
  • Lowercasing the text for case-insensitive matching.
  • Tokenizing the text into individual words or phrases.
  • Identifying keywords or patterns indicative of specific skills.

Matching with Available Skills

  • Compare the extracted information from the case description to a list of available skills.
  • This list could be stored in a custom object containing skill names and descriptions.
  • It could be retrieved dynamically from an external skill management system.

Deployment of Custom Routing Engine

  • Deploy the RoutingManager Class to Salesforce Org


Demo (Stage-9): Handle Case Record Change Event (Flow/Process Builder Approach)

  • Go to Setup
  • Search for Process Builder
  • Create a Process for Case Change Record Event
  • Make sure Case Description is not blank
  • Invoke the RoutingManager Class using Action Type “Apex”

Conclusion

With this custom Case Routing Engine powered by Apex code, you can automate case assignment based on real-time agent skills and availability. This not only streamlines your service operations but also ensures cases reach the most qualified agents for faster resolution and happier customers.

Trailblazer Profile | LinkedIn | Salesforce Blog | Facebook | Youtube Channel | WhatsApp Community

Comments