Task

Access the Task API. You can instantiate a Task.Client to receive tasks from a different application. Please check Task.TaskClientApiEvents for the full list of events that a Task.Client can subscribe to.

Example

The following example listens for incoming tasks.

const client = new Task.Client({
  project: "<project-id>",
  token: "<api-token>",
  contexts: ['office']
})

client.on('task.received', (payload) => {
  console.log('Task Received', payload)
  // Do something with the payload...
})

From a different process, even on a different machine, you can then send tasks:

await Task.send({
  project: "<project-id>",
  token: "<api-token>",
  context: 'office',
  message: { hello: ['world', true] },
})

Interfaces

Functions

send

Const send(params): Promise<void>

Send a job to your Task Client in a specific context.

Parameters

NameType
paramsTaskSendParams

Returns

Promise<void>

Example

Send a task with a message to then make an outbound Call.

const message = {
  'action': 'call',
  'from': '+18881112222'
  'to': '+18881113333'
}

await Task.send({
  project: "<project-id>",
  token: "<api-token>",
  context: 'office',
  message: message,
})