Activity Resource
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.
Info
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:
-
Your application can
update a Worker's Activity
by posting to the Worker instance resource and providing the SID if any of the Activities in the Workspace.
-
If a Reservation times out, the Worker is placed in the
TimeoutActivity
identified by the Workspace. By default this is
Offline
.
-
When a new Worker is created, the Worker is placed in the
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:
-
When the Worker is assigned a Task, the Worker is placed in the
ReservationActivity
identified by the TaskQueue that assigns the Worker the Task. By default this is the
Reserved
Activity.
-
When a Worker accepts a Task, the Worker is placed in the
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.
Warning
Pagination is not supported under this resource. Please avoid usage of the page
query parameter.
Property nameTypePIIDescription
The SID of the Account that created the Activity resource.
Pattern: ^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.
date_createdstring<date-time>
date_updatedstring<date-time>
The string that you assigned to describe the Activity resource.
The unique string that we created to identify the Activity resource.
Pattern: ^WA[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the Workspace that contains the Activity.
Pattern: ^WS[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The absolute URL of the Activity resource.
POST https://taskrouter.twilio.com/v1/Workspaces/{WorkspaceSid}/Activities
Info
The maximum amount of Activities allowed for any given Workspace is 100.
Property nameTypeRequiredPIIDescription
WorkspaceSidSID<WS>required The SID of the Workspace that the new Activity belongs to.
Pattern: ^WS[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
Property nameTypeRequiredPIIDescription
FriendlyNamestringrequired 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.
_21// Download the helper library from https://www.twilio.com/docs/node/install
_21const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_21// Find your Account SID and Auth Token at twilio.com/console
_21// and set the environment variables. See http://twil.io/secure
_21const accountSid = process.env.TWILIO_ACCOUNT_SID;
_21const authToken = process.env.TWILIO_AUTH_TOKEN;
_21const client = twilio(accountSid, authToken);
_21async function createActivity() {
_21 const activity = await client.taskrouter.v1
_21 .workspaces("WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_21 friendlyName: "NewAvailableActivity",
_21 console.log(activity.accountSid);
_13 "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_13 "date_created": "2014-05-14T10:50:02Z",
_13 "date_updated": "2014-05-14T23:26:06Z",
_13 "friendly_name": "NewAvailableActivity",
_13 "sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_13 "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities/WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_13 "workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_13 "workspace": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
GET https://taskrouter.twilio.com/v1/Workspaces/{WorkspaceSid}/Activities/{Sid}
Property nameTypeRequiredPIIDescription
WorkspaceSidSID<WS>required The SID of the Workspace with the Activity resources to fetch.
Pattern: ^WS[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the Activity resource to fetch.
Pattern: ^WA[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
_19// Download the helper library from https://www.twilio.com/docs/node/install
_19const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_19// Find your Account SID and Auth Token at twilio.com/console
_19// and set the environment variables. See http://twil.io/secure
_19const accountSid = process.env.TWILIO_ACCOUNT_SID;
_19const authToken = process.env.TWILIO_AUTH_TOKEN;
_19const client = twilio(accountSid, authToken);
_19async function fetchActivity() {
_19 const activity = await client.taskrouter.v1
_19 .workspaces("WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_19 .activities("WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_19 console.log(activity.accountSid);
_13 "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_13 "date_created": "2014-05-14T10:50:02Z",
_13 "date_updated": "2014-05-14T23:26:06Z",
_13 "friendly_name": "New Activity",
_13 "sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_13 "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities/WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_13 "workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_13 "workspace": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
GET https://taskrouter.twilio.com/v1/Workspaces/{WorkspaceSid}/Activities
Info
By default, this will return the first 50 Activities. Supply a PageSize parameter to fetch more than 50 Activities. See paging for more information.
Property nameTypeRequiredPIIDescription
WorkspaceSidSID<WS>required The SID of the Workspace with the Activity resources to read.
Pattern: ^WS[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
Property nameTypeRequiredPIIDescription
FriendlyNamestringOptional The friendly_name
of the Activity resources to read.
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.
Minimum: 1
Maximum: 1000
The page index. This value is simply for client state.
Minimum: 0
The page token. This is provided by the API.
_18// Download the helper library from https://www.twilio.com/docs/node/install
_18const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_18// Find your Account SID and Auth Token at twilio.com/console
_18// and set the environment variables. See http://twil.io/secure
_18const accountSid = process.env.TWILIO_ACCOUNT_SID;
_18const authToken = process.env.TWILIO_AUTH_TOKEN;
_18const client = twilio(accountSid, authToken);
_18async function listActivity() {
_18 const activities = await client.taskrouter.v1
_18 .workspaces("WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_18 .activities.list({ limit: 20 });
_18 activities.forEach((a) => console.log(a.accountSid));
_26 "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_26 "date_created": "2014-05-14T10:50:02Z",
_26 "date_updated": "2014-05-14T23:26:06Z",
_26 "friendly_name": "New Activity",
_26 "sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_26 "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities/WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_26 "workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_26 "workspace": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
_26 "first_page_url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities?Available=true&FriendlyName=friendly_name&PageSize=50&Page=0",
_26 "next_page_url": null,
_26 "previous_page_url": null,
_26 "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities?Available=true&FriendlyName=friendly_name&PageSize=50&Page=0"
POST https://taskrouter.twilio.com/v1/Workspaces/{WorkspaceSid}/Activities/{Sid}
Property nameTypeRequiredPIIDescription
WorkspaceSidSID<WS>required The SID of the Workspace with the Activity resources to update.
Pattern: ^WS[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the Activity resource to update.
Pattern: ^WA[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
Property nameTypeRequiredPIIDescription
FriendlyNamestringOptional 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
.
_19// Download the helper library from https://www.twilio.com/docs/node/install
_19const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_19// Find your Account SID and Auth Token at twilio.com/console
_19// and set the environment variables. See http://twil.io/secure
_19const accountSid = process.env.TWILIO_ACCOUNT_SID;
_19const authToken = process.env.TWILIO_AUTH_TOKEN;
_19const client = twilio(accountSid, authToken);
_19async function updateActivity() {
_19 const activity = await client.taskrouter.v1
_19 .workspaces("WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_19 .activities("WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_19 .update({ friendlyName: "another_name" });
_19 console.log(activity.accountSid);
_13 "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_13 "date_created": "2014-05-14T10:50:02Z",
_13 "date_updated": "2014-05-14T23:26:06Z",
_13 "friendly_name": "another_name",
_13 "sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_13 "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities/WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_13 "workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_13 "workspace": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
DELETE https://taskrouter.twilio.com/v1/Workspaces/{WorkspaceSid}/Activities/{Sid}
Property nameTypeRequiredPIIDescription
WorkspaceSidSID<WS>required The SID of the Workspace with the Activity resources to delete.
Pattern: ^WS[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the Activity resource to delete.
Pattern: ^WA[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
_17// Download the helper library from https://www.twilio.com/docs/node/install
_17const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_17// Find your Account SID and Auth Token at twilio.com/console
_17// and set the environment variables. See http://twil.io/secure
_17const accountSid = process.env.TWILIO_ACCOUNT_SID;
_17const authToken = process.env.TWILIO_AUTH_TOKEN;
_17const client = twilio(accountSid, authToken);
_17async function deleteActivity() {
_17 await client.taskrouter.v1
_17 .workspaces("WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_17 .activities("WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")