new Twilio.TaskRouter.Supervisor(token [, options])
Parameters:
| Name | Type | Argument | Description |
|---|---|---|---|
token |
string | The string token |
|
options |
WorkerOptions |
<optional> |
Fires:
Extends
Members
-
<readonly> accountSid :string
-
Type:
- string
- Inherited From:
-
activities
-
- Inherited From:
-
<readonly> activity
-
- Inherited From:
-
<readonly> attributes :Record.<any, any>
-
Type:
- Record.<any, any>
- Inherited From:
-
channels
-
- Inherited From:
-
<readonly> dateActivityChanged :Date
-
Type:
- Date
- Inherited From:
-
<readonly> dateCreated :Date
-
Type:
- Date
- Inherited From:
-
<readonly> dateStatusChanged :Date
-
Type:
- Date
- Inherited From:
-
<readonly> dateUpdated :Date
-
Type:
- Date
- Inherited From:
-
<readonly> friendlyName :string
-
Type:
- string
- Inherited From:
-
<readonly> name :string
-
Type:
- string
- Inherited From:
-
reservations
-
- Inherited From:
-
<readonly> sid :string
-
Type:
- string
- Inherited From:
-
version :string
-
Type:
- string
- Inherited From:
-
<readonly> workerActivitySid :string
-
Type:
- string
- Inherited From:
-
<readonly> workerSid :string
-
Type:
- string
- Inherited From:
-
<readonly> workspaceSid :string
-
Type:
- string
- Inherited From:
Methods
-
_bumpVersion()
-
bumps the worker version
- Inherited From:
-
createTask(to, from, workflowSid, taskQueueSid [, options])
-
Create a Task
Parameters:
Name Type Argument Description tostring The contact uri of the customer. Stored in the Task's attributes as "outbound_to"
fromstring The contact uri of the Worker. Stored in the Task's attributes as "from"
workflowSidstring The Sid of the Workflow this Task should belong to
taskQueueSidstring The Sid of the TaskQueue this Task should belong to, used for reporting purposes only
optionsWorkerTaskOptions <optional>
- Inherited From:
Returns:
- Rejected if unable to create a Task on behalf of the Worker. Returns the TaskSid of the created Task.
- Type
- Promise.<string>
-
disconnect()
-
Gracefully disconnect the client.
- Inherited From:
Returns:
- Type
- void
-
fetchLatestVersion()
-
Fetch the last version of this Worker
- Inherited From:
Returns:
- Type
- Promise.<this>
-
getLogger(prefix)
-
Parameters:
Name Type Description prefixstring - Inherited From:
Returns:
- Type
- Logger
-
getRoutes()
-
- Inherited From:
Returns:
- Type
- Routes
-
monitor(taskSid, reservationSid [, extraParams])
-
Add this Supervisor to an ongoing Reservation by Sid.
Parameters:
Name Type Argument Description taskSidstring The sid of the Task to add a monitor to.
reservationSidstring The sid of the Reservation to add a monitor to.
extraParamsRecord.<any, any> <optional>
An object containing extra params to append to the payload.
Returns:
Promise
-
setAttributes(attributes)
-
Update attributes
Parameters:
Name Type Description attributesRecord.<any, any> A JSON describing the Worker's attributes
- Inherited From:
Returns:
- Rejected if the attributes cannot be set
- Type
- Promise.<this>
-
setWorkerActivity(workerSid, activitySid [, options])
-
Sets the worker activity for a given worker based on the provided workerSid and activitySid.
Parameters:
Name Type Argument Description workerSidstring The SID of the worker.
activitySidstring The SID of the activity to set for the worker.
optionsObject <optional>
An object containing extra params to append to the payload.
Throws:
-
If workerSid or activitySid are not strings.
- Type
- TypeError
Returns:
Returns a Worker
- Type
- Promise.<Worker>
-
-
setWorkerAttributes(workerSid, attributes)
-
Sets the attributes of a worker.
Parameters:
Name Type Description workerSidstring The SID of the worker.
attributesRecord.<string, any> The attributes to set for the worker.
Throws:
-
If workerSid is not a string or attributes is not an object.
- Type
- TypeError
Returns:
Returns a Worker
- Type
- Promise.<Worker>
-
-
updateToken(newToken)
-
Update token
Parameters:
Name Type Description newTokenstring The new token that should be used for authentication
- Inherited From:
Returns:
- Emits error if unable to update token
- Type
- void
Events
-
activityUpdated
-
Worker activity has updated
Parameters:
Name Type Description workerWorker The updated Worker
- Inherited From:
-
attributesUpdated
-
Worker attributes have updated
Parameters:
Name Type Description workerWorker The updated Worker
- Inherited From:
-
disconnected
-
The signaling layer has lost the websocket connection
Parameters:
Name Type Description reasonObject The reason the Worker websocket disconnected
- Inherited From:
-
error
-
An error has occurred
Parameters:
Name Type Description errorError The Error that occurred
- Inherited From:
-
monitor
-
Add this Supervisor to an ongoing Reservation by Sid.
Parameters:
Name Type Argument Description taskSidstring The sid of the Task to add a monitor to.
reservationSidstring The sid of the Reservation to add a monitor to.
extraParamsObject <optional>
An object containing extra params to append to the payload.
-
ready
-
Worker is ready to listen for events and take action
- Inherited From:
-
reservationCreated
-
A Reservation has been created for the Worker
Parameters:
Name Type Description reservationReservation The created Reservation
- Inherited From:
-
reservationFailed
-
Worker was unable to receive a Reservation for the Task it created
Parameters:
Name Type Description taskObject The raw Task-like payload that failed to generate a Reservation
- Inherited From:
-
tokenExpired
-
The Worker token has expired
- Inherited From:
-
tokenUpdated
-
The Worker token has successfully updated
- Inherited From: