Activities describe the current status of your Workers, which determines whether they are eligible to receive task assignments. Workers are always set to a single Activity.
TaskRouter pre-populates new Workspaces with "Offline", "Unavailable", and "Available" Activities. Add your own Activities to the list to get a more granular understanding of the way your Workers are spending their time!
Each Activity has:
A FriendlyName, which describes the Worker's state in human-readable terms, and
An Availability, which is a Boolean that determines whether Workers are available for task assignment. The value cannot be changed after the Activity is created.
If a Worker is performing an Activity that has an availability of "true", it means that Worker is ready to have Tasks assigned to it. If a Worker is set to an Activity with an availability of "false", it means the Worker is not able to accept new Tasks and will not be considered for assignment.
By moving Workers from unavailable to available Activities you signal to TaskRouter that the Worker can be assigned new Tasks. When TaskRouter assigns the Worker a Task, it will automatically move the Worker to an unavailable Activity, so that the Worker is not assigned new Tasks while they are occupied. On completion of their work, the Worker can be moved to an available Activity to begin accepting new Tasks again.
The current Activity for a given Worker is changed in the following operations:
TimeoutActivity
identified by the Workspace. By default this is Offline
.DefaultActivity
identified by the Workspace, unless a specific ActivitySid is passed. By default, this is Offline
.In addition, a single-tasking Workspace supports two additional automatic state transitions:
ReservationActivity
identified by the TaskQueue that assigns the Worker the Task. By default this is the Reserved
Activity.AssignmentActivity
identified by the TaskQueue that assigns the Worker the Task. By default this is the Busy
Activity.In a multitasking Workspace, a Worker's state does not automatically update when a Task is assigned or accepted.
Pagination is not supported under this resource. Please avoid usage of the page
query parameter.
The SID of the Account that created the Activity resource.
^AC[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
Whether the Worker is eligible to receive a Task when it occupies the Activity. A value of true
, 1
, or yes
indicates the Activity is available. All other values indicate that it is not. The value cannot be changed after the Activity is created.
The date and time in GMT when the resource was created specified in ISO 8601 format.
The date and time in GMT when the resource was last updated specified in ISO 8601 format.
The unique string that we created to identify the Activity resource.
^WA[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the Workspace that contains the Activity.
^WS[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
POST https://taskrouter.twilio.com/v1/Workspaces/{WorkspaceSid}/Activities
The maximum amount of Activities allowed for any given Workspace is 100.
The SID of the Workspace that the new Activity belongs to.
^WS[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
application/x-www-form-urlencoded
A descriptive string that you create to describe the Activity resource. It can be up to 64 characters long. These names are used to calculate and expose statistics about Workers, and provide visibility into the state of each Worker. Examples of friendly names include: on-call
, break
, and email
.
Whether the Worker should be eligible to receive a Task when it occupies the Activity. A value of true
, 1
, or yes
specifies the Activity is available. All other values specify that it is not. The value cannot be changed after the Activity is created.
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function createActivity() {11const activity = await client.taskrouter.v112.workspaces("WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")13.activities.create({14available: true,15friendlyName: "NewAvailableActivity",16});1718console.log(activity.accountSid);19}2021createActivity();
1{2"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",3"available": true,4"date_created": "2014-05-14T10:50:02Z",5"date_updated": "2014-05-14T23:26:06Z",6"friendly_name": "NewAvailableActivity",7"sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",8"url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities/WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",9"workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",10"links": {11"workspace": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"12}13}
GET https://taskrouter.twilio.com/v1/Workspaces/{WorkspaceSid}/Activities/{Sid}
The SID of the Workspace with the Activity resources to fetch.
^WS[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the Activity resource to fetch.
^WA[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function fetchActivity() {11const activity = await client.taskrouter.v112.workspaces("WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")13.activities("WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")14.fetch();1516console.log(activity.accountSid);17}1819fetchActivity();
1{2"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",3"available": true,4"date_created": "2014-05-14T10:50:02Z",5"date_updated": "2014-05-14T23:26:06Z",6"friendly_name": "New Activity",7"sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",8"url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities/WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",9"workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",10"links": {11"workspace": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"12}13}
GET https://taskrouter.twilio.com/v1/Workspaces/{WorkspaceSid}/Activities
By default, this will return the first 50 Activities. Supply a PageSize parameter to fetch more than 50 Activities. See paging for more information.
The SID of the Workspace with the Activity resources to read.
^WS[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
Whether return only Activity resources that are available or unavailable. A value of true
returns only available activities. Values of '1' or yes
also indicate true
. All other values represent false
and return activities that are unavailable.
How many resources to return in each list page. The default is 50, and the maximum is 1000.
1
Maximum: 1000
The page token. This is provided by the API.
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function listActivity() {11const activities = await client.taskrouter.v112.workspaces("WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")13.activities.list({ limit: 20 });1415activities.forEach((a) => console.log(a.accountSid));16}1718listActivity();
1{2"activities": [3{4"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",5"available": true,6"date_created": "2014-05-14T10:50:02Z",7"date_updated": "2014-05-14T23:26:06Z",8"friendly_name": "New Activity",9"sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",10"url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities/WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",11"workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",12"links": {13"workspace": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"14}15}16],17"meta": {18"first_page_url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities?Available=true&FriendlyName=friendly_name&PageSize=50&Page=0",19"key": "activities",20"next_page_url": null,21"page": 0,22"page_size": 50,23"previous_page_url": null,24"url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities?Available=true&FriendlyName=friendly_name&PageSize=50&Page=0"25}26}
POST https://taskrouter.twilio.com/v1/Workspaces/{WorkspaceSid}/Activities/{Sid}
The SID of the Workspace with the Activity resources to update.
^WS[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the Activity resource to update.
^WA[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
application/x-www-form-urlencoded
A descriptive string that you create to describe the Activity resource. It can be up to 64 characters long. These names are used to calculate and expose statistics about Workers, and provide visibility into the state of each Worker. Examples of friendly names include: on-call
, break
, and email
.
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function updateActivity() {11const activity = await client.taskrouter.v112.workspaces("WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")13.activities("WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")14.update({ friendlyName: "another_name" });1516console.log(activity.accountSid);17}1819updateActivity();
1{2"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",3"available": true,4"date_created": "2014-05-14T10:50:02Z",5"date_updated": "2014-05-14T23:26:06Z",6"friendly_name": "another_name",7"sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",8"url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities/WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",9"workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",10"links": {11"workspace": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"12}13}
DELETE https://taskrouter.twilio.com/v1/Workspaces/{WorkspaceSid}/Activities/{Sid}
The SID of the Workspace with the Activity resources to delete.
^WS[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the Activity resource to delete.
^WA[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function deleteActivity() {11await client.taskrouter.v112.workspaces("WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")13.activities("WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")14.remove();15}1617deleteActivity();