Use rules to route and assign cases

The case routing feature uses matching rules and assignment rules to identify customer service cases that meet certain conditions and then route those cases to customer service agents.

Create one or more matching rules that establish specific conditions that a case must meet before it can be routed to an agent. Then use an assignment rule to route those cases to agents based on product knowledge and availability. You can also invoke the MatchingRuleProcessor API to execute the matching rules and return a list of users (sys_ids).

Matching Rules

Matching rules are based on two defined sets of conditions, one that identifies specific case attributes and another that identifies the agent resources best suited to handle cases with these attributes. Matching rules are created using the Matching Rule form.

To identify case attributes, select a table that stores the task type (by default the Case table) and then use a condition builder to create one or more conditions that a case must meet before being routed. For example, you can build conditions for a specific account and product or for a specific product and priority level.

To identify an agent resource, use one of the following methods:
  • Simple: select the resource name from a list of users.
  • Advanced: build conditions that filter the available agent resources. These conditions can be based on user role, agent group, specific skills, work load, or agent availability.
  • Scripted: create a customized script to identify agent resources.

Assignment Rules

When the matching rule conditions are met, a case can be routed to a customer service agent using an assignment rule.
Note: Matching rules and assignment rules are independent records with no synchronization. If you make a change in the Applies to component of the matching rule, it is not reflected in the assignment rule

Create a matching rule

Create a matching rule for a customer service case that identifies the case attributes as well as the agent resources.

Before you begin

Role required: admin

Procedure

  1. Navigate to System Policy > Rules > Matching Rules.
  2. Click New at the top of the Matching Rules list.
  3. Fill in the fields on the Matching Rule form.
    This form contains the following sections:
    • Basic rule information
    • Applies to: use this section to create rule conditions
    • Resource: use this section to create agent and agent group conditions
    Table 1. Matching Rule Form
    Field Description
    Name The name of the rule.
    Execution order The order in which this rule is to be executed. Similar to business rules, matching rules are processed based on execution order, from the lowest to the highest.
    Active Enable this check box to activate the rule.
    Applies To
    Table The table that stores the task for which the matching rule is being created. The default is the Case table (sn_customerservice_case).
    Conditions Use the buttons in this field to build one or more conditions on the selected table. A condition is made up of a selected field, an operator, and a value. Add conditions using the AND and OR buttons. Delete conditions by clicking the Delete button to the right of a condition.
    Resource
    Matching The type of resource matching method.

    Use the Simple method to assign a case to a specific agent. Select the agent name in the User field.

    Use the Advanced method to create a specific set of resource conditions. Then use the condition builder to identify these conditions.

    Use the Scripted method to create a customized script for identifying resources, with the goal of returning a list of users that have the same skills as the task. The task under consideration is set in the context of the script. For example:

    //current has the task record for which the rule is being executed.
    var task = current;
    var skills = task.getValue("skills");
    var skillUtil = new global.SkillsUtils();
    var skilledUsers = skillUtil.getAllSkilledUserIds(skills);
    return skilledUsers;
    User This field changes depending on the resource matching type selected in the Matching field.

    For the Simple matching type, use this field to select a user name.

    For the Advanced matching type, use the buttons in this field to build one or more conditions to identify a resource. These conditions can be based on user role, agent group, specific skills, work load, or agent availability.
    • Sorting on Work load in the ascending order amounts to least loaded ordering of resources.
    • Sorting on Last assigned time in the ascending order amounts to round robin ordering of resources.

    A condition is made up of a selected field, an operator, and a value. Add conditions using the AND and OR buttons. Delete conditions by clicking the Delete button to the right of a condition.

    Schedule based filtering

    This field applies to the Advanced matching type. Enable this check box to filter resources that are in schedule (work hours) at the time of routing.

    Script For the Scripted matching type, use this field to create a customized script for identifying resources. An example script is included. The expected return from a customized script is an array of resource sys_ids.
  4. Click Submit.
    After submitting, the rule appears in the Matching Rules list.

Create an assignment rule

Create a rule that assigns those cases that meet the matching rule criteria to a customer service agent.

Before you begin

Role required: admin

Procedure

  1. Navigate to System Policy > Rules > Matching Rules.
  2. Open the desired matching rule.
  3. Click the Create assignment rule related link.
    This displays the Assignment Rule form associated with the selected matching rule.
  4. Fill in the fields on the Assignment Rule form.
    Table 2. Assignment rule form
    Field Description
    Name The descriptive name for the assignment rule.
    Active An indicator of whether the assignment rule is active. Only active assignment rules take effect.
    Applies to
    Table

    The table with the records that the assignment rule applies to.

    Note: The list shows only tables and database views that are in the same scope as the assignment rule. If you select a custom table that extends the task table, you must clear the instance cache by navigating to https://<instance_name>.service-now.com/cache.do in order for the assignment rule to work.
    Conditions The conditions in which the assignment rule will apply.
    Assign to
    User The user which will be assigned the event.
    Group The group which will be assigned the event.
    Script
    Script A script to determine advanced assignment rule functionality. The current.variable_pool set of variables is available.
    Other fields
    Match conditions Choices are:
    • Any - Assignment Rule will apply if any of the conditions are met.
    • All - Assignment rule will apply if all of the conditions are met.
    Order A number to determine priority over conflicting assignment rules. If there are conflicting assignment rules, rules with lower Order values will take precedence over rules with higher Order values. If the Order values are all set to the same number the assignment rule with the first matching condition is run with precedence over the others. Only one assignment rule will run against a record, the first with a matching condition.
  5. Click Update.

Invoke the MatchingRuleProcessor API

After you create one or more matching rules, you can invoke the MatchingRuleProcessor API and run the rules.

Before you begin

Role required: sn_customerservice_agent, sn_customerservice_manager, admin

About this task

The result is a list of users (sys_ids), which you can use for case routing and assignment.

The matching engine can be invoked using the processAndGetCandidates method of the matchingRuleProcessor class. Pass in the task record and the number of resources. The result is an array of resource sys_ids.

The matching rules are processed based on the number stored in the rule’s Execution Order field.

Reverse matching

Reverse matching uses the same matching rules to match tasks to a resource rather than resources to a task.

Before you begin

Role required: sn_customerservice_agent, sn_customerservice_manager, admin

About this task

The resource matching engine can match resources and tasks in two ways:
  • Forward: matches resources for a task
  • Reverse: matches tasks for a resource

The same matching rule can be used for both forward and reverse matching. In the customer service application, you can use reverse matching to determine which call the next available agent should take. Reverse matching returns a list of case sys_ids instead of user sys_ids. When using reverse matching, you can also limit the cases returned to a specific set.

The following example shows how to use reverse matching.

MatchingRuleProcessor.processAndGetCandidates(resource, taskLimit, "sn_customerservice_case", "reverse", false, [<array of cases to consider>])