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 to
string The contact uri of the customer. Stored in the Task's attributes as "outbound_to"
from
string The contact uri of the Worker. Stored in the Task's attributes as "from"
workflowSid
string The Sid of the Workflow this Task should belong to
taskQueueSid
string The Sid of the TaskQueue this Task should belong to, used for reporting purposes only
options
WorkerTaskOptions <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 prefix
string - 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 taskSid
string The sid of the Task to add a monitor to.
reservationSid
string The sid of the Reservation to add a monitor to.
extraParams
Record.<any, any> <optional>
An object containing extra params to append to the payload.
Returns:
Promise
-
setAttributes(attributes)
-
Update attributes
Parameters:
Name Type Description attributes
Record.<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 workerSid
string The SID of the worker.
activitySid
string The SID of the activity to set for the worker.
options
Object <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 workerSid
string The SID of the worker.
attributes
Record.<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 newToken
string 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 worker
Worker The updated Worker
- Inherited From:
-
attributesUpdated
-
Worker attributes have updated
Parameters:
Name Type Description worker
Worker The updated Worker
- Inherited From:
-
disconnected
-
The signaling layer has lost the websocket connection
Parameters:
Name Type Description reason
Object The reason the Worker websocket disconnected
- Inherited From:
-
error
-
An error has occurred
Parameters:
Name Type Description error
Error The Error that occurred
- Inherited From:
-
monitor
-
Add this Supervisor to an ongoing Reservation by Sid.
Parameters:
Name Type Argument Description taskSid
string The sid of the Task to add a monitor to.
reservationSid
string The sid of the Reservation to add a monitor to.
extraParams
Object <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 reservation
Reservation The created Reservation
- Inherited From:
-
reservationFailed
-
Worker was unable to receive a Reservation for the Task it created
Parameters:
Name Type Description task
Object 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: