How to use the twilio.TaskRouterClient function in twilio

To help you get started, we’ve selected a few twilio examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github TwilioDevEd / api-snippets / rest / taskrouter / worker-reservations / call / example-1.2.x.js View on Github external
// Download the Node helper library from twilio.com/docs/node/install
// These vars are your accountSid and authToken from twilio.com/user/account
var twilio = require('twilio');

var accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
var authToken = "your_auth_token";
var workspaceSid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
var workerSid = "WKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
var reservationSid = "WRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

var client = new twilio.TaskRouterClient(accountSid, authToken, workspaceSid);

// call using a reservation
client.workspace.workers(workerSid).reservations(reservationSid).update({
    instruction: 'call',
    callFrom: '+15558675309',
    callUrl: 'http://example.com/agent_answer',
    callStatusCallbackUrl: 'http://example.com/agent_answer_status_callback',
    callAccept: 'true'
}, function(err, reservation) {
    console.log(reservation.reservation_status);
    console.log(reservation.worker_name);
});
github TwilioDevEd / api-snippets / rest / taskrouter / statistics / workers / example-1 / example-1.2.x.js View on Github external
// Download the Node helper library from twilio.com/docs/node/install
// These vars are your accountSid and authToken from twilio.com/user/account
var twilio = require('twilio');

var accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
var authToken = "your_auth_token";
var workspaceSid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

var client = new twilio.TaskRouterClient(accountSid, authToken, workspaceSid);

client.workspace.workers.statistics.get({}, function(err, responseData) {
    if(!err) {
        console.log(responseData.cumulative.reservations_accepted);
    }
});
github TwilioDevEd / api-snippets / rest / taskrouter / workspaces / list / get / example-1 / example-1.2.x.js View on Github external
// Download the Node helper library from twilio.com/docs/node/install
// These vars are your accountSid and authToken from twilio.com/user/account
var twilio = require('twilio');

var accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
var authToken = "your_auth_token";
var workspaceSid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

var client = new twilio.TaskRouterClient(accountSid, authToken, workspaceSid);

client.workspaces.list(function(err, data) {
    data.workspaces.forEach(function(workspace) {
        console.log(workspace.friendly_name);
    });
});
github TwilioDevEd / api-snippets / rest / taskrouter / statistics / workflow / example-1 / example-1.2.x.js View on Github external
// Download the Node helper library from twilio.com/docs/node/install
// These vars are your accountSid and authToken from twilio.com/user/account
var twilio = require('twilio');

var accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
var authToken = "your_auth_token";
var workspaceSid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
var workflowSid = "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

var client = new twilio.TaskRouterClient(accountSid, authToken, workspaceSid);

client.workspace.workflows(workflowSid).statistics.get({}, function(err, responseData) {
    if(!err) {
        console.log(responseData.cumulative.avg_task_acceptance_time);
        console.log(responseData.cumulative.tasks_created);
        console.log(responseData.realtime.tasks_by_status.pending);
        console.log(responseData.realtime.tasks_by_status.assigned);
    }
});
github TwilioDevEd / api-snippets / rest / taskrouter / workers / list / get / example-1 / example-1.2.x.js View on Github external
// Download the Node helper library from twilio.com/docs/node/install
// These vars are your accountSid and authToken from twilio.com/user/account
var twilio = require('twilio');

var accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
var authToken = "your_auth_token";
var workspaceSid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

var client = new twilio.TaskRouterClient(accountSid, authToken, workspaceSid);

client.workspace.workers.list(function(err, data) {
    data.workers.forEach(function(worker) {
        console.log(worker.friendly_name);
    })
});
github TwilioDevEd / api-snippets / rest / taskrouter / reservations / dequeue / example-1.2.x.js View on Github external
// Download the Node helper library from twilio.com/docs/node/install
// These vars are your accountSid and authToken from twilio.com/user/account
var twilio = require('twilio');

var accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
var authToken = "your_auth_token";
var workspaceSid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
var taskSid = "WTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
var reservationSid = "WRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

var client = new twilio.TaskRouterClient(accountSid, authToken, workspaceSid);

// dequeue a reservation
client.workspace.tasks(taskSid).reservations(reservationSid).update({
    instruction: 'dequeue',
    dequeueFrom: '+18001231234'
}, function(err, reservation) {
    console.log(reservation.reservation_status);
    console.log(reservation.worker_name);
});
github TwilioDevEd / api-snippets / rest / taskrouter / tasks / instance / post / example-1 / example-1.2.x.js View on Github external
// Download the Node helper library from twilio.com/docs/node/install
// These vars are your accountSid and authToken from twilio.com/user/account
var twilio = require('twilio');

var accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
var authToken = "your_auth_token";
var workspaceSid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
var taskSid = "WTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

var client = new twilio.TaskRouterClient(accountSid, authToken, workspaceSid);

// update a task's attributes
client.workspace.tasks(taskSid).update({
    attributes: '{"type":"support"}'
}, function(err, task) {
    console.log(task.attributes);
});

// cancel a task
client.workspace.tasks(taskSid).update({
    assignmentStatus: 'canceled',
    reason: 'waiting too long'
}, function(err, task) {
    console.log(task.assignment_status);
    console.log(task.reason);
});
github TwilioDevEd / api-snippets / rest / taskrouter / taskqueues / instance / delete / example-1 / example-1.2.x.js View on Github external
// Download the Node helper library from twilio.com/docs/node/install
// These vars are your accountSid and authToken from twilio.com/user/account
var twilio = require('twilio');

var accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
var authToken = "your_auth_token";
var workspaceSid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
var taskQueueSid = "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

var client = new twilio.TaskRouterClient(accountSid, authToken, workspaceSid);

client.workspace.taskQueues(taskQueueSid).delete();
github TwilioDevEd / api-snippets / rest / taskrouter / workspaces / instance / delete / example-1 / example-1.2.x.js View on Github external
// Download the Node helper library from twilio.com/docs/node/install
// These vars are your accountSid and authToken from twilio.com/user/account
var twilio = require('twilio');

var accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
var authToken = "your_auth_token";
var workspaceSid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

var client = new twilio.TaskRouterClient(accountSid, authToken, workspaceSid);

client.workspace.delete();
github drobtravels / universal-contact-center-be / functions / createTaskFromEmail / src / index.js View on Github external
export default function(event, context) {
  var params = {
    type: 'email',
    fromEmail: event.FromEmail,
    name: event.FromName,
    message: event.Message,
    subject: event.Subject,
    messageID: event.MessageID,
    date: event.Date
  }

  console.log('create task with params', params)
  var client = new twilio.TaskRouterClient(event.credentials.accountSid, event.credentials.authToken, event.credentials.workspaceSid);
  client.workspace.tasks.create({ attributes: JSON.stringify(params) }).then( (task) => {
    context.succeed({});
  }, (error) => { context.fail(error) });
}