Skip to content

Instantly share code, notes, and snippets.

@tommyvn
Last active June 16, 2022 07:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tommyvn/62a6c4dc574430e06f3dbcf528511953 to your computer and use it in GitHub Desktop.
Save tommyvn/62a6c4dc574430e06f3dbcf528511953 to your computer and use it in GitHub Desktop.
mve slack's bolt to test with localhost.run
const { App, LogLevel, ExpressReceiver } = require('@slack/bolt');
// this app is by default listening for events/commands/messages/etc on the /slack/events path
const app = new App({
token: process.env.SLACK_BOT_TOKEN,
logLevel: LogLevel.DEBUG,
signingSecret: process.env.SLACK_SIGNING_SECRET,
});
/* Add functionality here */
app.command('/yolo', async ({ command, ack, say }) => {
// Acknowledge command request
await ack();
await say(`${command.text}`);
});
app.error((error) => {
// Check the details of the error to handle cases where you should retry sending a message or stop the app
console.error(error);
});
(async () => {
// Start the app
await app.start(process.env.PORT || 3000);
console.log('⚡️ Bolt app is running!');
})();
@tommyvn
Copy link
Author

tommyvn commented Aug 31, 2020

run this and in another terminal run ssh -R 80:localhost:3000 plan@ssh.localhost.run. Configure the slack command in your app with the https domain name returned from localhost.run and the commains path: https://????.localhost.run/slack/events

@sjtower
Copy link

sjtower commented Dec 20, 2021

This solved my issue. I saw 404 error codes when I tried to create my first slash command. The Slack Bot would simply respond with /command failed with the error "dispatch_failed"

Thank you very much for this tip, I found it at the end of about 8 hours of troubleshooting & searching.

I also found the answer here: https://stackoverflow.com/questions/63665120/slash-command-dispatch-failed/65709852#65709852

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment