Skip to content

Commit

Permalink
fixed callback task
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Damm committed Jul 21, 2020
1 parent 4a483b9 commit 9a7056a
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions controllers/tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,26 @@ const chatHelper = require('./helpers/chat-helper.js');
const videoHelper = require('./helpers/video-helper.js');

module.exports.createCallback = function (req, res) {
taskrouterHelper
.createTask(req.configuration.twilio.workflowSid, req.body)
.then((task) => {
res.status(200).end();
})
.catch((error) => {
res.status(500).send(res.convertErrorToJSON(error));
});
const attributes = {
title: 'Callback request',
text: req.body.text,
channel: 'callback',
name: req.body.name,
team: req.body.team,
phone: req.body.phone
};

try {
const task = await taskrouterHelper.createTask(attributes);

const response = {
taskSid: task.sid
};

res.status(200).json(response);
} catch (error) {
res.status(500).json(res.convertErrorToJSON(error));
}
};

module.exports.createChat = function (req, res) {
Expand Down

0 comments on commit 9a7056a

Please sign in to comment.