Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// 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);
});
// 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);
}
});
// 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);
});
});
// 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);
}
});
// 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);
})
});
// 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);
});
// 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);
});
// 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();
// 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();
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) });
}