So I am trying to create a Slack app that asks users to choose from two options let say option 1 and option 2. Now sending the options is going fine however if the button is pressed there is no response from slack to the google apps script I am using.
const options = {
"method": "post",
"charset" : 'UTF-8',
"contentType": "application/json",
"payload": JSON.stringify({
token: auth,
channel: channel,
as_user: true,
"text": text,
attachments: [
{
"fallback" : "This did not work.",
"callback_id": randomId,
"attachment_type": "default",
"actions": [
{
"name": "ButtionOption1",
"text": "Option 1",
"type": "button",
"value": "Option1"
},
{
"name": "ButtionOption2",
"text": "Option 2",
"type": "button",
"value": "Option2"
}
]
}
]
})};
options.headers = { "Authorization": "Bearer " + auth }
var response = JSON.parse(UrlFetchApp.fetch(url, options));
console.log(response)
However when I try to respond there is just a nothing. I can see that the script is also not called.
My doPost(e)
function looks like:
function doPost(e) {
console.log("Started and writing reaction")
var e_payload = e.parameter.payload;
var parsed_payload = (e_payload !== undefined) ? JSON.parse(e_payload) : null;
console.log(parsed_payload)
try {
if (parsed_payload != null && parsed_payload.type == "url_verification") {
console.log("Verify the Challenge")
var v = JSON.parse(e.postData.contents);
return ContentService.createTextOutput(v.challenge);
}
} catch (e) {
}
If I try to let Slack enable events there is also no response if I want to verify. There appears an error saying:
Your URL didn’t respond with the value of the challenge parameter.
However I can see the script did not run in the logs.