Skip to contentSkip to navigationSkip to topbar
Page toolsOn this page
Looking for more inspiration?Visit the

Activity Based Routing


Activity-based routing lets you evaluate routing expressions against a Worker's Activity state, so you can target or exclude Workers based on the Activity they are in.

Match a Worker against multiple Activities

match-a-worker-against-multiple-activities page anchor
worker.activity_name in ['Generally Available', 'High Value Tasks']

With activity-based routing, you can:

  • Route high-value Tasks to Workers even when they are scheduled to not receive general Tasks.
  • Transfer Tasks to Agents who are in Activities that are excluded from routing.
  • Designate an Activity that allows an agent to only accept a particular type of task.

Expression Syntax

expression-syntax page anchor

You can write TaskRouter Expressions using Activity Name or Activity SIDs, and you can compare against a single value or an array of values.

ActivityDescription
worker.activity_nameThe Friendly Name of the Activity Resource
worker.activity_sidThe SID of the Activity Resource
OperatorDescription
==Compares to a single Activity Name or SID
inChecks if the value is in an array of Activity Names or SIDs

You can mix and match these Activity references and operators to create various expressions, like:

Look for a match in an array of friendly names

look-for-a-match-in-an-array-of-friendly-names page anchor
worker.activity_name in ['Generally Available', 'High Value Tasks']

Check for equality with an activity SID

check-for-equality-with-an-activity-sid page anchor
worker.activity_sid == 'WAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'

The following examples show how to apply activity-based routing in a Workflow configuration.

This example contains two expressions:

  1. TaskRouter should route general Tasks to generally available Workers.
  2. For high-value Tasks, TaskRouter can route to general workers OR a collection of workers who are available for high-value Tasks only.

Workflow configuration with activity-based routing

workflow-configuration-with-activity-based-routing page anchor
1
{
2
task_routing: {
3
filters: [
4
{
5
filter_friendly_name: "General Routing",
6
expression: "high_value == false",
7
targets: [
8
{
9
queue: "WQxyz1",
10
expression: "worker.activity_name == 'General Avail'",
11
priority: "50"
12
}
13
]
14
}
15
{
16
filter_friendly_name: "High value Tasks",
17
expression: "high_value == true",
18
targets: [
19
{
20
queue: "WQxyz2",
21
expression: "worker.activity_name == 'Limited Avail' OR
22
worker.activity_name == 'General Avail'",
23
priority: "100"
24
}
25
]
26
},
27
]
28
}
29
}
30