Skip to content

Instantly share code, notes, and snippets.

@venetucci
Last active November 25, 2016 07:57
Show Gist options
  • Save venetucci/001946dcd89860f48b5cd1e949afdc9b to your computer and use it in GitHub Desktop.
Save venetucci/001946dcd89860f48b5cd1e949afdc9b to your computer and use it in GitHub Desktop.
function doPost(request) {
var params = request.parameters;
// Make sure that the request came from our slack integration.
if (params.token == "[OUTGOING WEBHOOK TOKEN]") {
// Get the spreadsheet
var sheets = SpreadsheetApp.openById('[YOUR SPREADSHEET ID]');
// Check command name. If it starts with add, then add to sheet, if it's list topics, then respond with list of topics.
var text = String(params.text);
if (text.match(/^add:/i)) {
addNewItemToSheet(sheets, params);
} else if (text.match(/^list topics/i)) {
listSheetNames(sheets, params.channel_name)
}
// If the token does not match then do nothing
} else {
return;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment