Skip to content

Instantly share code, notes, and snippets.

@glennblock
Last active December 25, 2016 03:44
Show Gist options
  • Save glennblock/290d84a3741fc5829a28a56863bc9a3e to your computer and use it in GitHub Desktop.
Save glennblock/290d84a3741fc5829a28a56863bc9a3e to your computer and use it in GitHub Desktop.
var request = require('request');
module.exports = function (ctx, req, res) {
res.setHeader('Content-Type', 'application/json');
res.end(JSON.stringify({text:':hourglass:'}));
var url = ctx.body.text;
var response_url = ctx.body.response_url;
var options = {
url: url,
headers: {
'User-Agent': 'webtask-slack'
}
}
request(options, function (error, response, body) {
if (!error && response.statusCode == 200) {
console.log("response received");
}
else {
console.log("error", error);
}
request.post({
url: response_url,
body: {text: body},
json: true
}, function (error, response, responseBody) {
});
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment