---
"@context": https://schema.org
"@type": TechArticle
"@id": https://www.twilio.com/docs/taskrouter/activity-based-routing#article
headline: Activity Based Routing
description: Use TaskRouter activity-based routing to target or exclude Workers based on their Activity state, so you can route high-value Tasks and control Worker eligibility.
url: https://www.twilio.com/docs/taskrouter/activity-based-routing
inLanguage: en
dateModified: 2026-07-20T14:57:47.000Z
author:
  "@type": Organization
  name: Twilio Developer Education Team
publisher:
  "@type": Organization
  name: Twilio
---

# Activity Based Routing

Activity-based routing lets you evaluate routing expressions against a Worker's [Activity](/docs/taskrouter/api/activity) state, so you can target or exclude Workers based on the Activity they are in.

```javascript title="Match a Worker against multiple Activities"
worker.activity_name in ['Generally Available', 'High Value Tasks']
```

With activity-based routing, you can:

* Route high-value [Tasks](/docs/taskrouter/api/task) to [Workers](/docs/taskrouter/api/worker) 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

You can write [TaskRouter Expressions](/docs/taskrouter/expression-syntax) using Activity Name or Activity SIDs, and you can compare against a single value or an array of values.

| **Activity**           | **Description**                            |
| ---------------------- | ------------------------------------------ |
| `worker.activity_name` | The Friendly Name of the Activity Resource |
| `worker.activity_sid`  | The SID of the Activity Resource           |

| **Operator** | **Description**                                              |
| ------------ | ------------------------------------------------------------ |
| `==`         | Compares to a single Activity Name or SID                    |
| `in`         | Checks 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

```javascript
worker.activity_name in ['Generally Available', 'High Value Tasks']
```

### Check for equality with an activity SID

```javascript
worker.activity_sid == 'WAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
```

## Examples

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

### High Value Task Routing

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.

```json title="Workflow configuration with activity-based routing"
{
  task_routing: {
    filters: [
      {
        filter_friendly_name: "General Routing",
        expression: "high_value == false",
        targets: [
          {
            queue: "WQxyz1",
            expression: "worker.activity_name == 'General Avail'",
            priority: "50"
          }
        ]
      }
      {
        filter_friendly_name: "High value Tasks",
        expression: "high_value == true",
        targets: [
          {
            queue: "WQxyz2",
            expression: "worker.activity_name == 'Limited Avail' OR
                         worker.activity_name == 'General Avail'",
            priority: "100"
          }
        ]
      },
    ]
  }
}

```

## Next Steps

* Learn more about the [Activity Resource](/docs/taskrouter/api/activity).
* Learn how to [Skip based on Worker Availability](/docs/taskrouter/worker-presence).
* Understand TaskRouter [Workflows and their Configuration](/docs/taskrouter/workflow-configuration).
