Below is a simple node slack app that displays the built in multi user select
block element to a user. I want to handle the action when the user clicks the submit button in the input so I've set the action_id in the block and added an action listener as per the examples in the docs.
However, the action is not getting triggered; ngrok is showing the incoming /slack/actions
request but returning a 404.
What am I missing here?
const { App } = require('@slack/bolt');
const app = new App({
signingSecret: process.env.SLACK_SIGNING_SECRET,
token: process.env.SLACK_BOT_TOKEN,
});
app.event('app_home_opened', ({ event, say }) => {
say(`Hi <@${event.user}>!`);
const blocks = [{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Pick one or more items from the list"
},
"accessory": {
"type": "multi_users_select",
"action_id": "test_action",
"placeholder": {
"type": "plain_text",
"text": "Select items"
},
}
}];
say({ blocks });
});
app.action('test_action', async(req, res) => {
console.log(req);
console.log(res);
});
app.error(error => {
console.error(error);
});
(async () => {
await app.start(process.env.PORT || 3000);
})();
So I found the solution to this by looking at the receiver source code.
As far as I can tell this isn't documented anywhere, but if you want separate urls for events and actions you must specify them yourself:
const app = new App({
signingSecret: process.env.SLACK_SIGNING_SECRET,
token: process.env.SLACK_BOT_TOKEN,
endpoints: {
events: '/slack/events',
actions: '/slack/actions'
},
});