Created
August 17, 2017 17:42
-
-
Save codePrincess/c5368690edc1fb45f39c5d14e875846b to your computer and use it in GitHub Desktop.
get slack payload - save to backend
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function(context, req) { | |
//context.log('Node.js HTTP trigger function processed a request. RequestUri=%s', req.originalUrl); | |
context.log('push data:', req.body); | |
var str = req.body; | |
var results = str.split("&"); | |
var slackText = getParam(results, "text").replace(/\+/g, " ").replace(/mytodo/g, ""); | |
var userName = getParam(results, "user_name").replace(/\+/g, " "); | |
context.log(getParam(results, "token")); | |
context.log(getParam(results, "channel_name")); | |
context.log(userName); | |
context.log(slackText); | |
context.log(getParam(results, "trigger_word")); | |
context.bindings.outputRecord = { | |
title: slackText, | |
details: "von " + userName, | |
completed: false | |
} | |
context.done(); | |
}; | |
function getParam (array, paramName) { | |
for (i = 0; i < array.length; i++) { | |
var res = array[i]; | |
if (res.includes(paramName)) { | |
var param = res.substring(res.indexOf("=")+1); | |
return param; | |
} | |
} | |
return null; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment