Pagination is not supported under this resource. Please avoid usage of the page
query parameter.
TaskRouter creates a Reservation subresource whenever a Task is reserved for a Worker. TaskRouter will provide the details of this Reservation Instance subresource in the Assignment Callback HTTP request it makes to your application server.
You have multiple options for handling a Reservation:
The following details the REST API.
Important: If you do not respond with how to handle your Reservation within the TaskReservationTimeout
configured on a Workflow, then the Reservation will timeout and the Task will be available for other workers.
1GET /v1/Workspaces/{WorkspaceSid}/Tasks/{TaskSid}/Reservations/{ReservationSid}2
Returns the single reservation resource identified by {ReservationSid}.
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 fetchTaskReservation() {11const reservation = await client.taskrouter.v112.workspaces("WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")13.tasks("WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")14.reservations("WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")15.fetch();1617console.log(reservation.accountSid);18}1920fetchTaskReservation();
1{2"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",3"date_created": "2014-05-14T10:50:02Z",4"date_updated": "2014-05-15T16:03:42Z",5"links": {6"task": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",7"worker": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",8"workspace": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"9},10"reservation_status": "accepted",11"sid": "WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",12"task_sid": "WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",13"url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Reservations/WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",14"worker_name": "Doug",15"worker_sid": "WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",16"workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"17}
A Reservation has the following properties.
Field | Description |
---|---|
Sid | The unique ID of this Reservation. |
AccountSid | The ID of the Account that owns this Task |
WorkspaceSid | The ID of the Workspace that this task is contained within. |
TaskSid | The ID of the reserved Task |
WorkerSid | The ID of the reserved Worker |
WorkerName | Human readable description of the Worker that is reserved |
ReservationStatus | The current status of the reservation. See the table below for possible values. |
Possible values for ReservationStatus:
Status | Description |
---|---|
accepted | The Reservation was accepted by the Worker. |
canceled | The Reservation was canceled because the reservation timeout was reached. |
completed | The Reservation was marked as completed. |
pending | A Worker has been reserved for this task and TaskRouter is waiting on a reservation response. |
rejected | The Reservation was rejected by the Worker. |
rescinded | The Reservation was removed from the Worker. |
timeout | The Reservation timed out waiting for a response. When this happens, the Task will remain in the queue and TaskRouter will attempt to assign the Task to the next eligible Worker. |
wrapping | The Worker has finished the primary work and is finishing additional duties for the Reservation. |
1POST /v1/Workspaces/{WorkspaceSid}/Tasks/{TaskSid}/Reservations/{ReservationSid}2
To indicate that a Worker has accepted or rejected a Reservation, you make an HTTP POST
request to a Reservation instance resource URI.
You can issue a simple Accept or Reject request. You can also issue an Instruction, similar to Responding to an Assignment Callback. We'll detail what parameters need to be provided for each method:
Accepting a reservation means that the worker will work on the task, but you will need to do whatever work is required to connect the details of that task to the worker. You can think of accept as the bare minimum option for task acceptance. For voice tasks, the other methods described below are supersets of accept.
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 updateTaskReservation() {11const reservation = await client.taskrouter.v112.workspaces("WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")13.tasks("WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")14.reservations("WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")15.update({ reservationStatus: "accepted" });1617console.log(reservation.accountSid);18}1920updateTaskReservation();
1{2"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",3"date_created": "2014-05-14T10:50:02Z",4"date_updated": "2014-05-15T16:03:42Z",5"links": {6"task": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",7"worker": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",8"workspace": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"9},10"reservation_status": "accepted",11"sid": "WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",12"task_sid": "WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",13"url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Reservations/WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",14"worker_name": "Doug",15"worker_sid": "WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",16"workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"17}
Field | Required? | Description |
---|---|---|
ReservationStatus | Yes | accepted . Specifying accepted means the Worker has received the Task and will process it. TaskRouter will no longer consider this task eligible for assignment, and no other Worker will receive this Task. (🏢 not PII ) |
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 updateTaskReservation() {11const reservation = await client.taskrouter.v112.workspaces("WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")13.tasks("WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")14.reservations("WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")15.update({ reservationStatus: "rejected" });1617console.log(reservation.accountSid);18}1920updateTaskReservation();
1{2"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",3"date_created": "2014-05-14T10:50:02Z",4"date_updated": "2014-05-15T16:03:42Z",5"links": {6"task": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",7"worker": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",8"workspace": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"9},10"reservation_status": "rejected",11"sid": "WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",12"task_sid": "WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",13"url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Reservations/WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",14"worker_name": "Doug",15"worker_sid": "WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",16"workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"17}
Field | Required? | Description |
---|---|---|
ReservationStatus | Yes | rejected . Specifying rejected means the Worker has refused the assignment and TaskRouter will attempt to assign this Task to the next eligible Worker. (🏢 not PII ) |
WorkerActivitySid | No | If rejecting a reservation, change the worker that is tied to this reservation to the supplied activity. If not provided, the WorkerPreviousActivitySid on the Reservation will be used. (🏢 not PII ) |
Important: Tasks are automatically canceled after 1,000 rejections.
Please note: Although Tasks have always been cancelled after 1,000 rejections, the documentation previously incorrectly showed that Tasks are automatically cancelled after 10 rejections. If your solution requires Tasks to be cancelled after 10 rejections instead, please contact our support team for help.
Please see Manually accepting or rejecting a reservation for more information.
Conference instruction is the recommended way to connect calls between customer and agents. This should be used in almost all cases instead of dequeue or call for call center scenarios
Conference instruction takes care of a lot of the call orchestration which you would otherwise do yourself. For a given call represented by a task in TaskRouter, issuing a conference instruction will:
contact_uri
of the worker, or the provided to
fieldNote that conference instruction works out of the box with calls that have been in TaskRouter using the native TaskRouter integration. If you are creating the task manually for a voice call, in order to use conference instruction you must at minimum include in the Task Attributes {"call_sid" : "<callsid>", "to" : "<E.164 to number>"}
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 updateTaskReservation() {11const reservation = await client.taskrouter.v112.workspaces("WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")13.tasks("WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")14.reservations("WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")15.update({16conferenceStatusCallbackEvent: [17"start",18"end",19"join",20"leave",21"mute",22"hold",23],24from: "+18001231234",25instruction: "conference",26statusCallback: "https://www.example.com/ConferenceEvents",27});2829console.log(reservation.accountSid);30}3132updateTaskReservation();
1{2"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",3"date_created": "2014-05-14T10:50:02Z",4"date_updated": "2014-05-15T16:03:42Z",5"links": {6"task": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",7"worker": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",8"workspace": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"9},10"reservation_status": "accepted",11"sid": "WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",12"task_sid": "WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",13"url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Reservations/WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",14"worker_name": "Doug",15"worker_sid": "WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",16"workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"17}
Conference instruction uses the Conference Participants API. All values valid for that API can be provided as part of the conference instruction. Note that those parameter names are not replicated here. Please refer to linked documentation for valid values.
Note that the Participant API parameters provided apply to the worker leg of the call, not the customer leg of the call. In particular, note that endConferenceOnExit can only be set for the worker leg. If the customer hangs up if you want the agent call leg to be torn down you should do that via API.
Field | Required? | Description |
---|---|---|
Instruction | Yes | Conference (🏢 not PII ) |
To | No | The contact URI of the Worker. A phone number or client ID. Must be a string. Required if the worker's attributes do not include a contact_uri property. (📇 PII ) |
From | No | The caller ID for the call to the worker. Must be a string. Note: This needs to be a verified Twilio number. If you need this to be the original caller number, please contact Support (📇 PII ) |
PostWorkActivitySid | No | (Deprecated) The activity to move a worker to after executing a conference instruction. Not valid in multi-tasking workspaces. (🏢 not PII ) |
Timeout | No | The integer number of seconds that Twilio should allow the phone associated with contact_uri to ring before assuming there is no answer. Default is 60 seconds, the maximum is 999 seconds. Note, you could set this to a low value, such as 15, to hang up before reaching an answering machine or voicemail. (🏢 not PII ) |
All other Participant API possible parameters except for the following: caller-id byoc recording-track label recording-status-callback-event conference-recording-status-callback-event coaching call-sid-to-coach call-reason speaker | No | See linked documentation |
Note: A property of contact_uri
is required on the WorkerAttributes to indicate whom to call. See more information on this here.
In most situations we would recommend you use Conference Instruction instead of dequeue
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 updateTaskReservation() {11const reservation = await client.taskrouter.v112.workspaces("WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")13.tasks("WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")14.reservations("WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")15.update({16dequeueFrom: "+18001231234",17instruction: "dequeue",18});1920console.log(reservation.accountSid);21}2223updateTaskReservation();
1{2"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",3"date_created": "2014-05-14T10:50:02Z",4"date_updated": "2014-05-15T16:03:42Z",5"links": {6"task": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",7"worker": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",8"workspace": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"9},10"reservation_status": "accepted",11"sid": "WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",12"task_sid": "WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",13"url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Reservations/WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",14"worker_name": "Doug",15"worker_sid": "WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",16"workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"17}
Field | Required? | Description |
---|---|---|
Instruction | Yes | Dequeue (🏢 not PII ) |
DequeueTo | No | The contact URI of the Worker. A phone number or client ID. Required if the worker's attributes do not include a contact_uri property. (📇 PII ) |
DequeueFrom | Yes | The caller ID for the call to the worker. Note: This needs to be a verified Twilio number. If you need this to be the original callee number, please contact Support (📇 PII ) |
DequeuePostWorkActivitySid | No | The activity to move a worker to after executing a dequeue instruction. (🏢 not PII ) |
DequeueRecord | No | The 'DequeueRecord' attribute lets you record both legs of a call. Set to "record-from-answer" to record the call from answer. Default to "do-not-record" which will not record the call. The RecordingUrl will be sent with DequeueStatusCallbackUrl. (🏢 not PII ) |
DequeueTimeout | No | The integer number of seconds that Twilio should allow the phone associated with contact_uri to ring before assuming there is no answer. Default is 60 seconds, the maximum is 999 seconds. Note, you could set this to a low value, such as 15, to hangup before reaching an answering machine or voicemail. (🏢 not PII ) |
DequeueStatusCallbackUrl | No | A URL that Twilio will send asynchronous webhook requests to on completed call event. **Note: TaskRouter sends "taskCallSid" as parameter with sid of the call that created the Task. This is very useful in the event a call to worker fails, where you could remove the original call from queue and send to voice mail or enqueue again with new workflow to route to different group of workers. (🏢 not PII ) |
DequeueStatusCallbackEvent | No | The call progress events that will be sent via webhooks on a worker's call. Available values are initiated, ringing, answered, and completed. If you want to receive multiple events, please provide multiple DequeueStatusCallbackEvent values as individual parameters in the POST request. If no event is specified, defaults to completed. For example to receive webhooks on answered and completed events pass "DequeueStatusCallbackEvent=answered&DequeueStatusCallbackEvent=completed". Please click here for more details. (🏢 not PII ) |
Note: A property of contact_uri
is required on the WorkerAttributes to indicate whom to call. See more information on this here.
Please see issuing a Dequeue Instruction for more information.
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 updateTaskReservation() {11const reservation = await client.taskrouter.v112.workspaces("WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")13.tasks("WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")14.reservations("WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")15.update({16callAccept: true,17callFrom: "+15558675310",18callStatusCallbackUrl: "http://example.com/agent_answer_status_callbac",19callUrl: "http://example.com/agent_answer",20instruction: "call",21});2223console.log(reservation.accountSid);24}2526updateTaskReservation();
1{2"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",3"date_created": "2014-05-14T10:50:02Z",4"date_updated": "2014-05-15T16:03:42Z",5"links": {6"task": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",7"worker": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",8"workspace": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"9},10"reservation_status": "accepted",11"sid": "WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",12"task_sid": "WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",13"url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Reservations/WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",14"worker_name": "Doug",15"worker_sid": "WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",16"workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"17}
Field | Required? | Description |
---|---|---|
Instruction | Yes | Call (🏢 not PII ) |
CallTo | No | The contact URI of the Worker. A phone number or client ID. Required if the worker's attributes do not include a contact_uri property. (📇 PII ) |
CallFrom | Yes | The caller ID to use when placing the outbound call (📇 PII ) |
CallUrl | Yes | A valid TwiML URI that is executed on the answering Worker's leg. (🏢 not PII ) |
CallAccept | No | If set to "true", the reservation will be accepted. Otherwise, a separate call to the REST API is responsible for moving the state to accept or reject. (🏢 not PII ) |
CallRecord | No | The 'CallRecord' attribute lets you record both legs of a call. Set to "record-from-answer" to record the call from answer. Default to "do-not-record" which will not record the call. The RecordingUrl will be sent with DequeueStatusCallbackUrl. (🏢 not PII ) |
CallTimeout | No | The integer number of seconds that Twilio should allow the phone associated with contact_uri to ring before assuming there is no answer. Default is 60 seconds, the maximum is 999 seconds. Note, you could set this to a low value, such as 15, to hangup before reaching an answering machine or voicemail. (🏢 not PII ) |
CallStatusCallbackUrl | No | A URL that Twilio will send asynchronous webhook requests to on completed call event. **Note: TaskRouter sends "taskCallSid" as parameter with sid of the call that created the Task. This is very useful in the event a call to worker fails, where you could remove the original call from queue and send to voice mail or enqueue again with new workflow to route to different group of workers. (🏢 not PII ) |
Note: A property of contact_uri
is required on the WorkerAttributes to indicate whom to call. See more information on this here.
Please see issuing a Call Instruction for more information.
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 updateTaskReservation() {11const reservation = await client.taskrouter.v112.workspaces("WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")13.tasks("WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")14.reservations("WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")15.update({16instruction: "redirect",17redirectCallSid: "CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",18redirectUrl: "http://example.com/assignment_redirect",19});2021console.log(reservation.accountSid);22}2324updateTaskReservation();
1{2"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",3"date_created": "2014-05-14T10:50:02Z",4"date_updated": "2014-05-15T16:03:42Z",5"links": {6"task": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",7"worker": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",8"workspace": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"9},10"reservation_status": "accepted",11"sid": "WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",12"task_sid": "WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",13"url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Reservations/WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",14"worker_name": "Doug",15"worker_sid": "WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",16"workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"17}
Field | Required? | Description |
---|---|---|
Instruction | Yes | Redirect (🏢 not PII ) |
RedirectCallSid | Yes | The Twilio call sid of the call which was parked in the queue(via enqueue for example). (🏢 not PII ) |
RedirectUrl | Yes | A valid TwiML URI to redirect the call to. (🏢 not PII ) |
RedirectAccept | No | Boolean. If true, the reservation will be accepted, otherwise, it is your application's responsibility to accept or reject the task at a later point. Defaults to false. (🏢 not PII ) |
Please see Redirect a call to a new TwiML document for more information.
1GET /v1/Workspaces/{WorkspaceSid}/Tasks/{TaskSid}/Reservations2
Returns a representation of all the list of Reservations waiting for a Task identified by {TaskSid}.
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 listTaskReservation() {11const reservations = await client.taskrouter.v112.workspaces("WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")13.tasks("WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")14.reservations.list({ limit: 20 });1516reservations.forEach((r) => console.log(r.accountSid));17}1819listTaskReservation();
1{2"meta": {3"first_page_url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Reservations?PageSize=50&Page=0",4"key": "reservations",5"next_page_url": null,6"page": 0,7"page_size": 50,8"previous_page_url": null,9"url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Reservations?PageSize=50&Page=0"10},11"reservations": [12{13"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",14"date_created": "2014-05-14T10:50:02Z",15"date_updated": "2014-05-15T16:03:42Z",16"links": {17"task": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",18"worker": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",19"workspace": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"20},21"reservation_status": "accepted",22"sid": "WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",23"task_sid": "WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",24"url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Reservations/WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",25"worker_name": "Doug",26"worker_sid": "WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",27"workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"28}29]30}
Field | Description |
---|---|
WorkerSid | Returns the list of reservations for a task for a specified worker |
ReservationStatus | Returns the list of reservations for a task with a specified ReservationStatus |