Last active
June 16, 2022 07:11
-
-
Save tommyvn/62a6c4dc574430e06f3dbcf528511953 to your computer and use it in GitHub Desktop.
mve slack's bolt to test with localhost.run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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!'); | |
})(); |
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
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