Skip to content

Commit

Permalink
added findWorker, fixed chat task creation
Browse files Browse the repository at this point in the history
Matthias Damm committed Jul 21, 2020
1 parent 6b88f48 commit 7982613
Showing 2 changed files with 14 additions and 3 deletions.
9 changes: 9 additions & 0 deletions controllers/helpers/taskrouter-helper.js
Original file line number Diff line number Diff line change
@@ -17,6 +17,15 @@ module.exports.createTask = function (workflowSid, attributes) {
return client.taskrouter.workspaces(process.env.TWILIO_WORKSPACE_SID).tasks.create(data);
};

module.exports.findWorker = function (friendlyName) {
const filter = { friendlyName: friendlyName };

return client.taskrouter
.workspaces(process.env.TWILIO_WORKSPACE_SID)
.workers.list(filter)
.then((workers) => workers[0]);
};

module.exports.getOngoingTasks = function (name) {
return new Promise(function (resolve, reject) {
let query = {};
8 changes: 5 additions & 3 deletions controllers/tasks.js
Original file line number Diff line number Diff line change
@@ -26,7 +26,7 @@ module.exports.createChat = function (req, res) {
chatHelper
.createChannel(friendlyName, uniqueName)
.then((channel) => {
payload.channel = {
payload.chat = {
sid: channel.sid,
friendlyName: channel.friendlyName,
uniqueName: channel.uniqueName
@@ -58,15 +58,17 @@ module.exports.createVideo = function (req, res) {
let payload = {
identity: req.body.identity,
token: videoHelper.createAccessToken(req.body.identity, uid).toJwt(),
roomName: uid
video: {
name: uid
}
};

const attributes = {
title: 'Video request',
text: 'Customer requested video support on web page',
channel: 'video',
name: payload.identity,
roomName: payload.roomName
roomName: payload.video.name
};

taskrouterHelper

0 comments on commit 7982613

Please sign in to comment.