new Twilio.TaskRouter.Worker(token [, options] [, deps])
Parameters:
Name | Type | Argument | Description |
---|---|---|---|
token |
string | The string token |
|
options |
WorkerOptions |
<optional> |
|
deps |
WorkerDeps |
<optional> |
Properties:
Name | Type | Description |
---|---|---|
accountSid |
string | The sid of the Twilio account |
activities |
Map.<string, Activity> | The list of possible states a Worker can be |
activity |
Activity | |
activitySid |
string | |
activityName |
string | |
attributes |
Record.<any, any> | A JSON representation of the Worker's attributes |
available |
boolean | |
channels |
Map.<string, Channel> | The list of available Channels |
connectActivitySid |
string | |
dateCreated |
Date | The date this Worker was created |
dateStatusChanged |
Date | The date this Worker's activity was last changed |
dateUpdated |
Date | The date this Worker was last updated |
name |
string | The friendly name of the Worker |
reservations |
Map.<string, Reservation> | A list of pending Reservations for the Worker |
sid |
string | The sid of the Worker |
workspaceSid |
string | The sid of the Workspace owning this Worker |
workerSid |
string | The sid of the Worker, duplicates sid field for backwards compatibility |
workerActivitySid |
string | The sid of the Activity the Worker is currently in, duplicates activitySid field for backwards compatibility |
dateActivityChanged |
Date | The date when the Worker's state was last changed, duplicates dateStatusChanged field for backwards compatibility |
friendlyName |
string | The friendly name of the Worker, duplicates name field for backwards compatibility |
version |
string | The version of this Worker |
Fires:
Extends
- EventEmitter
Members
-
<readonly> accountSid :string
-
Type:
- string
-
activities
-
-
<readonly> activity
-
-
<readonly> attributes :Record.<any, any>
-
Type:
- Record.<any, any>
-
channels
-
-
<readonly> dateActivityChanged :Date
-
Type:
- Date
-
<readonly> dateCreated :Date
-
Type:
- Date
-
<readonly> dateStatusChanged :Date
-
Type:
- Date
-
<readonly> dateUpdated :Date
-
Type:
- Date
-
<readonly> friendlyName :string
-
Type:
- string
-
<readonly> name :string
-
Type:
- string
-
reservations
-
-
<readonly> sid :string
-
Type:
- string
-
version :string
-
Type:
- string
-
<readonly> workerActivitySid :string
-
Type:
- string
-
<readonly> workerSid :string
-
Type:
- string
-
<readonly> workspaceSid :string
-
Type:
- string
Methods
-
_bumpVersion()
-
bumps the worker version
-
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>
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.
Returns:
- Type
- void
-
fetchLatestVersion()
-
Fetch the last version of this Worker
Returns:
- Type
- Promise.<this>
-
getLogger(prefix)
-
Parameters:
Name Type Description prefix
string Returns:
- Type
- Logger
-
getRoutes()
-
Returns:
- Type
- Routes
-
setAttributes(attributes)
-
Update attributes
Parameters:
Name Type Description attributes
Record.<any, any> A JSON describing the Worker's attributes
Returns:
- Rejected if the attributes cannot be set
- Type
- Promise.<this>
-
updateToken(newToken)
-
Update token
Parameters:
Name Type Description newToken
string The new token that should be used for authentication
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
-
attributesUpdated
-
Worker attributes have updated
Parameters:
Name Type Description worker
Worker The updated Worker
-
disconnected
-
The signaling layer has lost the websocket connection
Parameters:
Name Type Description reason
Object The reason the Worker websocket disconnected
-
error
-
An error has occurred
Parameters:
Name Type Description error
Error The Error that occurred
-
ready
-
Worker is ready to listen for events and take action
-
reservationCreated
-
A Reservation has been created for the Worker
Parameters:
Name Type Description reservation
Reservation The created Reservation
-
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
-
tokenExpired
-
The Worker token has expired
-
tokenUpdated
-
The Worker token has successfully updated