Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why slack slash command returns "http_client_error"

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:

screengrab of ngrok screenshot of slack

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:

slack_setup

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.

like image 309
pcdr Avatar asked Jan 31 '20 19:01

pcdr


People also ask

How do I enable slash command?

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.

How do you send commands in Slack?

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).


1 Answers

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. :)

like image 140
pcdr Avatar answered Sep 24 '22 21:09

pcdr