Search code examples
node.jschatbotslackslack-api

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.


Solution

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