Skip to content

Instantly share code, notes, and snippets.

@ErikKalkoken
Created August 6, 2019 15:05
Show Gist options
  • Save ErikKalkoken/fff3c91c5daa3e8ffb13a4d97d4013db to your computer and use it in GitHub Desktop.
Save ErikKalkoken/fff3c91c5daa3e8ffb13a4d97d4013db to your computer and use it in GitHub Desktop.
Slack Dialog with Google Apps Script
var SLACK_ACCESS_TOKEN = PropertiesService.getScriptProperties().getProperty('SLACK_ACCESS_TOKEN');
function doGet(e) {
return ContentService.createTextOutput("I am alive");
}
function doPost(e) {
var params = e.parameter;
var token = params.token;
var text = params.text;
var trigger_id = params.trigger_id;
var slackUrl = "https://slack.com/api/dialog.open";
var dialog = {
"token": SLACK_ACCESS_TOKEN,
"trigger_id": trigger_id,
"dialog": JSON.stringify({
"callback_id": "ryde-46e2b0",
"title": "Submit a Slack-Update",
"submit_label": "Update",
"elements": [
{
"type": "text",
"label": "Yesterday",
"name": "yesterday",
"placeholder": "What did you finish yesterday?"
},
{
"type": "text",
"label": "Today",
"name": "today",
"placeholder": "What will you work on today?"
},
{
"type": "text",
"label": "Blockers",
"name": "blockers",
"value": "None"
}
]
})
}
var options = {
'method' : 'post',
'payload' : dialog,
};
UrlFetchApp.fetch(slackUrl, options);
return ContentService.createTextOutput("");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment