bolt-js: slash commands result in `dispatch_failed`
Description
I’m using a localtunnel type service to send commands to my bot But on sending /commands, I just get an error message when sending to my local machine via the port forwarding tunnel.
/hint failed with the error "dispatch_failed"
the code works when deployed other commands work fine over the tunnel service.
is there anything special about slash commands? they seem to use http (or https) not sockets or anything fancy.
Describe your issue here.
What type of issue is this? (place an x
in one of the [ ]
)
- bug
- enhancement (feature request)
- question
- documentation related
- testing related
- discussion
Requirements (place an x
in each of the [ ]
)
- I’ve read and understood the Contributing guidelines and have done my best effort to follow them.
- I’ve read and agree to the Code of Conduct.
- I’ve searched for any related issues and avoided creating a duplicate issue.
Bug Report
bolt latest “@slack/bolt”: “^2.1.1”,
Reproducible in:
package version:
node version:
OS version(s):
Steps to reproduce:
setup app configure slash commands configure local tunnel service nothing arrives at server
Expected result:
slash command events
Actual result:
What actually happened
Attachments:
see above
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 15 (3 by maintainers)
Thanks for looping around on this issue @tommyvn!
Judging from #604 and this issue (#579), we may want to clarify that all incoming requests (actions/events/commands/etc) are received on
/slack/events
.If others find that @tommyvn hint toward
/slack/events
solves their issue, can you please add a 👍🏻 to this comment so that we know this is the problem. If it is, then I’ll try to update the docs!author of localhost.run here. I looked into this and I had this exact error. You need to make sure your Request URL in the screenshot @dcsan posted above has the event path in, ie: https://your-domain/slack/events. I posted a minimal viable example for commands at https://gist.github.com/tommyvn/62a6c4dc574430e06f3dbcf528511953 to hopefully hint others towards this solution. edit: removed unnecessary comments above after @stevengill set me on the right path on #604
EDIT: FIXED: Our staging and prod servers were running Bolt 2.6.1 (and my local an earlier version). Upgrading to 2.7 solved this issue, so I can only think something was funky in that Bolt version.
After a hiatus of a few months (just seemed to fix itself last time), I’ve had this issue again.
So, after several months of no issues, for the last week we’ve been getting a “dispatch_failed” error message when sending slash commands on staging and production environments. It’s working fine locally (using Ngrok for tunneling).
As the Bolt docs specify, we’re using the /slack/events endpoint for our slash commands and using the .command() method to listen for them. I’ve checked we have no typos on this.
The strange thing is, /slack/events is working nicely for all other events and giving a 200 response when hit, but when called from a slash command gives a 500 or sometimes a 401 and this error:
And if I add a new command in the App settings I see this in the logs:
It seems like something extra is needed to receive slash commands on slack/events in Bolt, but it’s not clear what/how.
Like I say, any other request to /slack/events gives a 200, and everything works nicely on my local machine using ngrok.
I’m stumped!
For what it’s worth, I’m facing the same issue with “local” development. If using NGROK tunnel I am able to hit it but when using NGINX it fails. I am able to hit my end-point manually and see expected responses but when I issue a slash command in Slack I get a failed response saying:
failed with the error "dispatch_failed"
When I turn off my local development instance I get a timeout instead.
As @mwbrooks provided a clear guide on this, let us close this issue now. If you have a similar question, please feel free to write in or create a new one with detailed information.
Big thanks to everyone for sharing the experiences (and solutions)! Reading through this thread, my feeling is that there are numerous reasons why Slash Commands may be resulting in the
dispatched_failed
. A checklist that might help others is:/slack/events
If you’re still having trouble, I’d suggest trying out Slack’s new Socket Mode feature. You can enable this for any app and Bolt 3 has built-in support. Once enabled, it will disable Request URL and use a direct socket connection between Slack and Bolt. Learn more about using Socket Mode in Bolt’s documentation.
Warning about Socket Mode: Once enabled, it will disable Request URL. You can always disable Socket Mode, but you can’t use both at the same time.
Using an API Gateway/Lambda endpoint with a /slack/events route is not resolving my “dispatch_failed” error, even though this approach typically works for handling Slack webhook events.
I created a webhook.site URL for the Request_URL and Slack events are posting to it without any issues. However, when I try to use an API endpoint on AWS instead, setting up API Gateway with a /slack/events POST route to a Lambda function, I still get “dispatch_failed” errors from Slack slash commands