Class: Task

Task

A Task represents an item of work


Properties:
Name Type Description
addOns Record.<any, any>

The addons attached to the Task

age number

The age of the Task in seconds

attributes Record.<any, any>

The attributes of the Task

dateCreated Date

The date the Task was created

dateUpdated Date

The date the Task was last updated

priority number

The priority of the Task

queueName string

The friendly name of the TaskQueue the Task is currently in

queueSid string

The sid of the TaskQueue the Task is currently in

reason string

The reason the Task was completed or canceled, if applicable

routingTarget string

The target Sid of the Worker, TaskQueue, or Workflow this Task will be routed to.

sid string

The sid of the Task

status string

The status of the Task. Options: ['pending', 'reserved', 'assigned', 'canceled', 'completed', 'wrapping']

taskChannelSid string

The sid of the Task Channel associated to the Task in MultiTask mode

taskChannelUniqueName string

The unique name of the Task Channel associated to the Task in MultiTask mode

timeout number

The number of seconds the Task is allowed to live

transfers Transfers

The IncomingTransfer and OutgoingTransfer related to this Task, if applicable

workflowName string

The name of the Workflow responsible for routing the Task

workflowSid string

The sid of the Workflow responsible for routing the Task

version string

The version of this Task

reservationSid string

The sid of Reservation

virtualStartTime Date

Optionally set starting time of the Task, in cases where the interaction between the customer and agents spans across multiple tasks. If not provided, defaults to dateCreated.

Fires:

Extends

  • EventEmitter

Members


<readonly> addOns :Record.<any, any>

Type:
  • Record.<any, any>

<readonly> age :number

Type:
  • number

<readonly> attributes :Record.<any, any>

Type:
  • Record.<any, any>

<readonly> dateCreated :Date

Type:
  • Date

<readonly> dateUpdated :Date

Type:
  • Date

<readonly> priority :number

Type:
  • number

<readonly> queueName :string

Type:
  • string

<readonly> queueSid :string

Type:
  • string

<readonly> reason :string

Type:
  • string

<readonly> reservationSid :string

Type:
  • string

<readonly> routingTarget :string

Type:
  • string

<readonly> sid :string

Type:
  • string

<readonly> status :'pending'|'reserved'|'assigned'|'canceled'|'completed'|'wrapping'

Type:
  • 'pending' | 'reserved' | 'assigned' | 'canceled' | 'completed' | 'wrapping'

<readonly> taskChannelSid :string

Type:
  • string

<readonly> taskChannelUniqueName :string

Type:
  • string

<readonly> timeout :number

Type:
  • number

<readonly> transfers :Transfers

Type:

<readonly> version :string

Type:
  • string

<readonly> virtualStartTime :Date

Type:
  • Date

<readonly> workflowName :string

Type:
  • string

<readonly> workflowSid :string

Type:
  • string

Methods


complete(reason)

Update the Task status to 'completed'

Parameters:
Name Type Description
reason string

The reason for completing the Task

Returns:
  • Rejected if the Task state could not be updated to 'completed'
Type
Promise.<this>

fetchLatestVersion()

Fetch the last version of this Task

Returns:
Type
Promise.<Task>

hold(targetWorkerSid, onHold, options)

Hold the worker's call leg in the Conference associated to this Task and specified TargetWorkerSid

Parameters:
Name Type Description
targetWorkerSid String

The target worker's sid which should be put onhold or unhold

onHold boolean

Whether to hold or unhold the specified worker's call leg in the Conference referenced by the Task

options TaskHoldOptions
Returns:
Type
Promise.<this>

kick(workerSid)

Kick another active Worker participant from the ongoing conference

Parameters:
Name Type Description
workerSid string

The Sid of the Worker who is currently in the conference that should be kicked

Returns:
  • Rejected if unable to kick the call leg of the targeted Worker in the Conference tied to the Task
Type
Promise.<this>

setAttributes(attributes)

Update the Task attributes to the given attributes.

Parameters:
Name Type Description
attributes Record.<any, any>

A JSON to update the attributes.

Returns:
  • Rejected if the attributes cannot be set
Type
Promise.<this>

setVirtualStartTime(date)

Set virtual start time of the Task.

Parameters:
Name Type Description
date Date

Virtual start time as a Date.

Returns:
  • Rejected if fails to set the time.
Type
Promise.<this>

<async> transfer(to [, options])

Transfer the Task to another entity.

Parameters:
Name Type Argument Description
to string

The Worker or TaskQueue entity sid to transfer the task to.

options TransferOptions <optional>
Returns:
Type
Promise.<this>

updateParticipant(options)

Update the Customer leg in the Conference associated to this Task

Parameters:
Name Type Description
options TaskParticipantOptions
Returns:
  • Rejected if unable to update the Customers' leg in the Conference tied to the Task
Type
Promise.<this>

wrapUp(options)

Update the Task status to 'wrapping' in a multi-task enabled Workspace

Parameters:
Name Type Description
options WrappingOptions
Returns:
  • Rejected if the Task state could not be updated to 'wrapping'
Type
Promise.<this>

Events


canceled

The Task was canceled

Parameters:
Name Type Description
task Task

The Task who was canceled


completed

The Task was completed

Parameters:
Name Type Description
task Task

The Task who was completed


transferAttemptFailed

An OutgoingTransfer attempt has been failed for Task

Parameters:
Name Type Description
outgoingTransfer OutgoingTransfer

The currently in process OutgoingTransfer


transferCanceled

An OutgoingTransfer has been canceled for Task

Parameters:
Name Type Description
outgoingTransfer OutgoingTransfer

The currently in process OutgoingTransfer


transferCompleted

An OutgoingTransfer has been competed for Task

Parameters:
Name Type Description
outgoingTransfer OutgoingTransfer

The currently in process OutgoingTransfer


transferFailed

An OutgoingTransfer has been failed for Task

Parameters:
Name Type Description
outgoingTransfer OutgoingTransfer

The currently in process OutgoingTransfer


transferInitiated

An OutgoingTransfer has been initiated for Task

Parameters:
Name Type Description
outgoingTransfer OutgoingTransfer

The currently in process OutgoingTransfer


updated

The attributes of this Task was updated

Parameters:
Name Type Description
task Task

The Task whose attributes were updated


wrapup

The Task was wrapped up

Parameters:
Name Type Description
task Task

The Task who was wrapped up