Skip to contentSkip to navigationSkip to topbar
On this page

Skipping based on Worker availability



Overview

overview page anchor

By default, when a Task is processing through a Workflow, a Task waits in a routing step until it's matched to a Worker or until a timeout moves it to the next routing step. If there are initially no matching Workers, you may want to skip to the next routing step immediately. To do this, use the Skip Timeout expression:

skip_if: workers.available == 0

The following special variables can be used to evaluate against the Activity of Workers. These variables are scoped to the Workers in the TaskQueue associated with the currently processing routing step.

ValueMeaning
workers.availableThe number of workers in queue that are in an Available activity state
workers.unavailableThe number of workers in queue that are in an Unavailable activity state
workers.WAxxThe number of workers in queue that are in the activity state corresponding to WAxx, where WAxx is a valid ActivitySid

Skip Timeout is evaluated only if a Task can't be assigned to a Worker immediately. Additionally, Skip Timeout is successful only if the expression evaluates to true. Therefore, TaskRouter skips a routing step in a Workflow when both of these conditions are met:

  • No Reservations are immediately created when a Task enters the routing step
  • The Skip Timeout expression evaluates to true
(information)

Info

If a Task skips a filter, it's evaluated as if the Task didn't match the filter expression. This is important when considering your default_filter behavior because, even though a Task may match one of the filter expressions, Tasks that skip a named filter still qualify for the default_filter.

To learn more about the behavior of the default filter, see the Workflow Overview.


Skipping based on capacity

skipping-based-on-capacity page anchor

The variables mentioned above only relate to the Activity of Workers. In a multitasking Workspace, Tasks are only assigned to Workers if they:

  • Match the rules of the routing step (for example, they're part of the selected TaskQueue and match the Workers expression)
  • Are in an Available Activity
  • Have capacity on the Task's channel

The expression 1==1 is useful here. Because 1==1 always evaluates to true, you can use it to skip the routing step if no Workers are available that match the above criteria.


Example Skip Timeout expressions:

  • 1==1
  • workers.available == 0
  • workers.WAxx < 2
  • workers.WAxx < 2 OR workers.WAyy < 2

Skip Timeout expressions must evaluate to true or false, support equality and comparison, and can be compounded with AND/OR logical operators.

1
{
2
"task_routing":{
3
"filters":[
4
{
5
"filter_friendly_name":"Sales filter",
6
"expression":"type == 'Sales'",
7
"targets":[
8
{
9
"queue":"WQ3935a4f744a241c1356c09310c2398e6",
10
"expression":"task.subSection == worker.specializedSubField",
11
"order_by":"worker.english_level ASC",
12
"priority":"1",
13
"skip_if": "workers.available == 0"
14
},
15
{
16
"priority":"1",
17
"queue":"WQ787b271950e0f7687ec432221e672ffa"
18
}
19
]
20
}
21
]
22
}
23
}