twilio.rest.resources.task_router

Workspaces

class twilio.rest.resources.task_router.Workspaces(*args, **kwargs)

A list of Workspace resources

create(friendly_name, **kwargs)

Create a Workspace.

Parameters:
  • friendly_name – Human readable description of this workspace (for example “Customer Support” or “2014 Election Campaign”).
  • event_callback_url – If provided, the Workspace will publish events to this URL. You can use this to gather data for reporting. See Workspace Events for more information.
  • template – One of the available template names. Will pre-configure this Workspace with the Workflow and Activities specified in the template. Currently “FIFO” is the only available template, which will configure Work Distribution Service with a set of default activities and a single queue for first-in, first-out distribution.
delete(sid)

Delete the given workspace

update(sid, **kwargs)

Update a Workspace with the given parameters.

All the parameters are describe above in create()

class twilio.rest.resources.task_router.Workspace(*args, **kwargs)

A Workspace resource. See the TaskRouter API reference <https://www.twilio.com/docs/taskrouter/workspaces>_ for more information.

sid

The unique ID of the Workspace

account_sid

The ID of the account that owns this Workspace

friendly_name

Human readable description of this workspace (for example “Sales Call Center” or “Customer Support Team”)

default_activity_sid

The ID of the default Activity that will be used when new Workers are created in this Workspace.

default_activity_name

The human readable name of the default activity. Read only.

timeout_activity_sid

The ID of the Activity that will be assigned to a Worker when a Task reservation times out without a response.

timeout_activity_name

The human readable name of the timeout activity. Read only.

event_callback_url

An optional URL where the Workspace will publish events. You can use this to gather data for reporting.

date_created

The time the Workspace was created, given as UTC in ISO 8601 format.

date_updated

The time the Workspace was last updated, given as UTC in ISO 8601 format.

Workflows

class twilio.rest.resources.task_router.Workflows(*args, **kwargs)

A list of Workflow resources

create(friendly_name, configuration, assignment_callback_url, **kwargs)

Create a Workflow.

Parameters:
  • friendly_name – A string representing a human readable name for this Workflow. Examples include ‘Inbound Call Workflow’ or ‘2014 Outbound Campaign’.
  • configuration – JSON document configuring the rules for this Workflow.
  • assignment_callback_url – A valid URL for the application that will process task assignment events.
  • fallback_assignment_callback_url – If the request to the assignment_callback_url fails, the assignment callback will be made to this URL.
  • task_reservation_timeout – An integer value controlling how long in seconds Work Distribution Service will wait for a confirmation response from your application after assigning a Task to a worker. Defaults to 120 seconds.
delete(sid)

Delete the given workflow

update(sid, **kwargs)

Update a Workflow with the given parameters.

All the parameters are describe above in create()

class twilio.rest.resources.task_router.Workflow(*args, **kwargs)

A Workflow resource.

See the TaskRouter API reference <https://www.twilio.com/docs/taskrouter/workflows>_ for more information.

sid

The unique ID of the Workflow.

account_sid

The ID of the account that owns this Workflow.

workspace_sid

The ID of the Workspace that contains this Workflow.

friendly_name

A human-readable description of this Workflow.

assignment_callback_url

The URL that will be called whenever a Task managed by this Workflow is assigned to a Worker.

fallback_assignment_callback_url

If the request to the assignment_callback_url fails, the assignment callback will be made to this URL.

configuration

A JSON document configuring the rules for this workflow.

task_reservation_timeout

Determines how long TaskRouter will wait for a confirmation response from your application after assigning a Task to a worker. Defaults to 120 seconds.

date_created

The time this workflow was created, as UTC in ISO 8601 format.

date_updated

The time this workflow was last updated, as UTC in ISO 8601 format.

Activities

class twilio.rest.resources.task_router.Activities(*args, **kwargs)

A list of Activity resources

create(friendly_name, available)

Create an Activity.

Parameters:
  • friendly_name – A human-readable name for the activity, such as ‘On Call’, ‘Break’, ‘Email’, etc. Must be unique in this Workspace. These names will be used to calculate and expose statistics about workers, and give you visibility into the state of each of your workers.
  • available – Boolean value indicating whether the worker should be eligible to receive a Task when they occupy this Activity. For example, a call center might have an activity named ‘On Call’ with an availability set to ‘false’.
delete(sid)

Delete the given activity

update(sid, **kwargs)

Update an Activity with the given parameters.

All the parameters are describe above in create()

Workers

class twilio.rest.resources.task_router.Workers(base_uri, auth, timeout, **kwargs)

A list of Worker resources

create(friendly_name, **kwargs)

Create a Workflow.

Parameters:
  • friendly_name – String representing user-friendly name for the Worker.
  • activity_sid – A valid Activity describing the worker’s initial state.
  • attributes – JSON object describing this worker. For example: { ‘email: 'Bob@foo.com‘, ‘phone’: ‘8675309’ }. This data will be passed to the Assignment Callback URL whenever Work Distribution Service assigns a Task to this worker.
delete(sid)

Delete the given worker

update(sid, **kwargs)

Update a Worker with the given parameters.

All the parameters are describe above in create()

class twilio.rest.resources.task_router.Worker(*args, **kwargs)

A Worker resource.

See the TaskRouter API reference <https://www.twilio.com/docs/taskrouter/workers>_ for more information.

sid

The unique ID of this Worker.

account_sid

The unique ID of the account that owns this worker.

workspace_sid

The unique ID of the Workspace that contains this worker.

friendly_name

A human-readable name for this worker.

attributes

A JSON object describing this worker. For example, for a Worker that handles English language phone calls:

‘{“language”:”english”,”task-type”:”phone”}’

These attributes determine which TaskQueue this worker will subscribe to. These attributes will also be passed to the Assignment Callback URL whenever TaskRouter assigns a Task to this worker, so you can also use this as a place to store information that you’ll need when routing a Task to the Worker (for example, the Worker’s phone number or Twilio Client name).

available

A Boolean value indicating whether the worker can be assigned another task. When true, the worker can be assigned a new task; when false, the worker will not be assigned any tasks.

activity_sid

The unique ID of the Activity this Worker is currently performing.

activity_name

A string describing the worker’s current activity. Workers may only perform Activities that exist in this Workspace.

date_created

The time this worker was created, given in UTC ISO 8601 format.

date_updated

The time this worker was last updated, given in UTC ISO 8601 format.

date_status_changed

The time of the last change to this worker’s activity. Used to calculate :class: Workflow statistics.

TaskQueues

class twilio.rest.resources.task_router.TaskQueues(base_uri, auth, timeout, **kwargs)

A list of TaskQueue resources

create(friendly_name, assignment_activity_sid, reservation_activity_sid, **kwargs)

Create a TaskQueue.

Parameters:
  • friendly_name – Human readable description of this TaskQueue (for example “Support - Tier 1”, “Sales” or “Escalation”)
  • assignment_activity_sid – ActivitySID to assign workers once a task is assigned for them.
  • reservation_activity_sid – ActivitySID to assign workers once a task is reserved for them.
delete(sid)

Delete the given task queue

update(sid, **kwargs)

Update a TaskQueue with the given parameters.

All the parameters are describe above in create()

class twilio.rest.resources.task_router.TaskQueue(*args, **kwargs)

A TaskQueue resource.

See the TaskRouter API reference <https://www.twilio.com/docs/taskrouter/taskqueues>_ for more information.

sid

The unique ID of this TaskQueue.

account_sid

The unique ID of the account that owns this TaskQueue.

workspace_sid

The unique ID of the Workspace that contains this TaskQueue.

friendly_name

Human-readable description of this TaskQueue (e.g. “Customer Support” or “Sales”).

target_workers

The worker selection expressions associated with this TaskQueue.

reservation_activity_sid

The Activity to assign a Worker when they are reserved for a Task from this TaskQueue. Defaults to ‘Reserved for Task’.

assignment_activity_sid

The Activity to assign a Worker when they accept a Task from this Taskqueue. Defaults to ‘Unavailable for Assignment’.

Tasks

class twilio.rest.resources.task_router.Tasks(*args, **kwargs)

A list of Task resources

create(attributes, workflow_sid, **kwargs)

Create a Task.

Parameters:
  • attributes – Url-encoded JSON string describing the attributes of this task. This data will be passed back to the Workflow’s AssignmentCallbackURL when the Task is assigned to a Worker. An example task: { ‘task_type’: ‘call’, ‘twilio_call_sid’: ‘...’, ‘customer_ticket_number’: ‘12345’ }.
  • workflow_sid – The workflow_sid for the Workflow that you would like to handle routing for this Task.
  • timeout – If provided, time-to-live for the task in seconds, before it is automatically canceled
delete(sid)

Delete the given task

update(sid, **kwargs)

Update a Task with the given parameters.

All the parameters are describe above in create()

class twilio.rest.resources.task_router.Task(*args, **kwargs)

A Task resource.

See the TaskRouter API reference <https://www.twilio.com/docs/taskrouter/tasks>_ for more information.

sid

The unique ID for this Task.

account_sid

The ID of the account that owns this Task.

workspace_sid

The ID of the Workspace that contains this Task.

workflow_sid

The ID of the Workflow that is responsible for routing this Task.

attributes

The user-defined JSON string describing the custom attributes of this work.

age

The number of seconds since this Task was created.

priority

The current priority score of the task, as assigned by the Workflow. Tasks with higher values will be assigned before tasks with lower values.

task_queue_sid

The ID of the current TaskQueue this task occupies, controlled by the Workflow.

assignment_status

A string representing the assignment state of the task. May be ‘pending’, ‘reserved’, ‘assigned’, or ‘canceled’.

reason

The reason the task was canceled (if applicable).

date_created

The date this task was created, as UTC in ISO 8601 format.

date_updated

The date this task was last updated, as UTC in ISO 8601 format.

Events

class twilio.rest.resources.task_router.Events(*args, **kwargs)
get_instances(params)

Query the list resource for a list of InstanceResources. Raises a TwilioRestException if requesting a page of results that does not exist.

Parameters:
  • params (dict) – List of URL parameters to be included in request
  • page_token (str) – Token of the page of results to retrieve
  • page_size (int) – The number of results to be returned.
Returns:

– the list of resources

list(**kwargs)
Returns a page of Event resources as a list. For paging
information see NextGenListResource
Parameters:
  • minutes – (Optional, Default=15) Definition of the interval in minutes prior to now.
  • start_date – (Optional, Default=15 minutes prior) Filter events by a start date.
  • end_date – (Optional, Default=Now) Filter events by an end date.
  • resource_sid – (Optional) Sid of the event resource.
  • event_type – (Optional) The type of event to filter by.
class twilio.rest.resources.task_router.Event(*args, **kwargs)

An Event resource representing a state change in a TaskRouter Workspace.

See the TaskRouter API reference <https://www.twilio.com/docs/taskrouter/events>_ for more information.

event_type

An identifier for this event.

account_sid

The unique ID of the Account that owns this Event.

description

A description of the event.

resource_type

The type of object this event is most relevant to (Task, Reservation, Worker).

resource_sid

The unique ID of the object this event is most relevant to.

event_date

The time this event was sent, in UTC ISO 8601 format.

event_data

Data about this specific Event.