30

I have went through creating the custom slash command configuration via slack and installed it on workspace. However when I run it I get this /testing failed with the error "dispatch_failed"

I tried multiple workspaces but same issue. Anyone experienced this?

enter image description here

Asim Zaidi
  • 27,016
  • 49
  • 132
  • 221

6 Answers6

23

So after a few tests, I found out that this is just a generic message of anything that fails at slack at this point. I have first my endpoint that was unreachable. So it was returning this message. I fixed that, used ngrok for tunnel so that I could debug and that is how I found this issue.

Also, this error can occur due to the following reasons as well.

  • Errors in code
  • Unreachable backend or Invalidly configured slash command in the app
Asim Zaidi
  • 27,016
  • 49
  • 132
  • 221
12

While the documentation tells you:

"use the Request URL is your base server link + "/slashcommand" after it"

This is incorrect. The request URL should be: "/slack/events"

Of course the command needs to match whats in the 'edit command' window and in the method '.command' in your app.js:

app.command('/flash-card', async ({ ack, body, client })

Simon Tower
  • 664
  • 3
  • 11
  • 27
Majnuel
  • 161
  • 1
  • 4
  • 3
    /slack/events part of your answer worked for when I got this error – eagles1283 Jan 30 '21 at 09:34
  • 1
    Thank you! I found this answer through https://github.com/slackapi/bolt-js/issues/579#issuecomment-683998460 – Simon Tower Dec 20 '21 at 18:53
  • 2
    To elaborate on what's linked in the issue above - Slack's Bolt framework DOES NOT use `/slack/command`. It confusingly ONLY uses `/slack/events` for everything. Bit of a gotcha. – Chris Hayes Jul 22 '22 at 22:03
2

If you're using ngrok http <port> to test in your localhost, be aware that a new ngrok public URL is created every time you run this command. So in https://api.slack.com/apps, in your app's Features, you may have to update your Slash Command' request URL with the current ngrok URL generated for you.

rafaelportela
  • 306
  • 1
  • 5
  • 9
2

This is also the error for a 404 Not Found.

If you're developing offline with ngrok, the 404 error can be seen in the terminal.

If you're deploying with serverless, ensure that you're handling the new endpoint /slack/command. One solution is to create a separate handler, i.e. /command.js

functions:
  slack:
    handler: app.handler
    events:
      - http:
          path: slack/events
          method: post
  command:
    handler: command.handler
    events:
      - http:
          path: slack/command
          method: post
joematune
  • 1,087
  • 10
  • 16
1

You need to set the Method in the Integration Settings to GET, is default to POST

DevOps
  • 11
  • 1
1

[If your code is executing and u still have this error]

In my case using Slackbolt with js I forgot to add

await ack();

in called function so Slack api throw error.

Prestionyk
  • 11
  • 1