I am wanting to create a slack app that listens for a message to be posted by a user and then responds with an ephemeral message for that user in the channel with some suggestions and buttons. I have a lambda subscribed to the Events API and it is receiving each message that is posted. I have another lambda set up to post the ephemeral message and when I call it from postman (through API Gateway) it does so successfully but when I try to press the buttons I get the error: this app responded with a 400 status code
I have specified the Request URL in the interactivity section of my slack app with the same URL that is used to invoke the Lambda that sends the message in the first place. When I check the logs, I get the first hit from postman, but after a button press I don't get any more pings.
I'm largely at a loss and not sure where to go from here, I read and re-read the slack docs and checked many stack overflow posts but none have helped me find an answer. Any help would be greatly appreciated.
Lambda that sends message:
const axios = require('axios')
exports.handler = async (event) => {
// TODO implement
console.log("Request: ", event)
const response = {
statusCode: 200,
};
let params = {
"channel": "hardcoded_channelID",
"user": "hardcoded_userID",
"text": "Hello World",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Hello"
}
},
{
"type": "divider"
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Suggestion 1"
}
},
{
"type": "actions",
"elements": [
{
"type": "button",
"text": {
"type": "plain_text",
"text": "Helpful"
},
"value": "helpful",
"action_id": "1_helpful"
},
{
"type": "button",
"text": {
"type": "plain_text",
"text": "Not Helpful"
},
"value": "notHelpful",
"action_id": "1_nothelpful"
},
{
"type": "button",
"style": "danger",
"text": {
"type": "plain_text",
"text": "Dismiss"
},
"value": "dismiss",
"action_id": "1_dismiss"
}
]
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Suggestion 2"
}
},
{
"type": "actions",
"elements": [
{
"type": "button",
"text": {
"type": "plain_text",
"text": "Helpful"
},
"value": "helpful",
"action_id": "2_heplful"
},
{
"type": "button",
"text": {
"type": "plain_text",
"text": "Not Helpful"
},
"value": "notHelpful",
"action_id": "2_nothelpful"
},
{
"type": "button",
"style": "danger",
"text": {
"type": "plain_text",
"text": "Dismiss"
},
"value": "dismiss",
"action_id": "2_dismiss"
}
]
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Suggestion 3"
}
},
{
"type": "actions",
"elements": [
{
"type": "button",
"text": {
"type": "plain_text",
"text": "Helpful"
},
"value": "helpful",
"action_id": "3_helpful"
},
{
"type": "button",
"text": {
"type": "plain_text",
"text": "Not Helpful"
},
"value": "notHelpful",
"action_id": "3_nothelpful"
},
{
"type": "button",
"style": "danger",
"text": {
"type": "plain_text",
"text": "Dismiss"
},
"value": "dismiss",
"action_id": "3_dismiss"
}
]
}
]
}
let config = {
method: 'post',
url: 'https://slack.com/api/chat.postEphemeral',
headers: {
'Authorization': 'Bearer xoxb-token',
'Content-Type': 'application/json'
},
data: params
};
const res = await axios(config);
console.log(res);
return response;
};