I'm trying to build a very simple Slackbot using the Bolt Framework. I'm using ngrok to run this locally and when I invoke a slash command, ngrok just shows:
According to the Bot documentation, the app uses app.command()
to handle slash commands. This is part of my code:
const {App, LogLevel} = require("@slack/bolt");
const app = new App({
token: "XXXX",
signingSecret: "XXXX",
logLevel: LogLevel.DEBUG
});
// The echo command simply echoes on command
app.command("/standup", async ({command, ack, say}) => {
// Acknowledge command request
ack();
say(`${command.text}`);
console.log("Entered into the app.command for /standUp");
});
Within Slack, the slash command is configured like this:
The bot works when interacting with messages, but just does receive and respond to Slash commands. I'm really new to this so any info would be great or just a push in the right direction.
Slash Commands are the new, exciting way to build and interact with bots on Discord. With Slash Commands, all you have to do is type / and you're ready to use your favorite bot. You can easily see all the commands a bot has, and validation and error handling help you get the command right the first time.
Slack has a lot of built-in slash commands that act as shortcuts for specific actions in Slack. You simply need to type the slash key (/) then followed by some keywords in any Slack channel or direct message to trigger specific actions in Slack (e.g. type /away to mark your status to “away” quickly).
I was able to figure out what the issue was. When I was trying above, I had the request url end with ../command
, but it needed to stay the same as the configuration for Event Subscriptions with ../slack/events/
.
I started to receive the commands after I made this change. As far as I can tell, this was not documented very well on Slack's docs, but I figured out the issue by seeing the configuration here and lots of trial and error. :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With