Hey friends,
I'm working on a Bolt app which uses the Adding Custom HTTP routes feature:
const { App, ExpressReceiver } = require("@slack/bolt")
const receiver = new ExpressReceiver({/* ... */})
receiver.router.get("/", (req, res) => res.send('Hello world'))
const app = new App({receiver, /* ... */})
_I'm personally using this feature to serve a OAuth login flow over HTTP that works together with the Slack app to log folks into another service._
Recently, I became aware of Socket Mode, which is helpful in working around having a public webhook in my development environment.
Enabling socketMode in the App quietly discards my custom receiver.
My request is two part-er:
App raised an error if you set socketMode and pass a customer receiver if the behaviour is to discard the receiver.socketMode and b) add custom HTTP routesx in one of the [ ])x in each of the [ ])socketMode on your appThe custom HTTP routes are accessible.
The custom HTTP routes are NOT accessible.
ps. Bolt was very straight forward to get started with and socketMode seems quite innovative and awesome! Thanks for your hard work on this. ❤️ ❤️ ❤️
Hey @johnboxall, it's good to hear from you 👋🏻
This is a use-case that we overlooked while designing the first release of socketMode, but it's an important one. I think your suggestions of an improvement for the current experience along with an enhancement to support custom routes with socketMode is a solid start for a discussion!
I believe @stevengill is going to weigh-in on this in a bit, so I'll leave it to him to start the discussion!
Hey @johnboxall!
Glad to see you are using Bolt!
🐛 BUG: It would be great if the App raised an error if you set socketMode and pass a customer receiver if the behaviour is to discard the receiver.
This is a great idea. SocketMode is a receiver in BoltJS. So you aredefinitelyy trying to use 2 receivers which isn't allowed and we should throw an error for this.
⚡ ENHANCEMENT: I'm not entirely sure how this would work, but I'd like to a) use socketMode and b) add custom HTTP routes
This isn't possible today. In SocketModeReceiver, we do use the http module to create routes if you want to support OAuth. See https://github.com/slackapi/bolt-js/blob/main/src/receivers/SocketModeReceiver.ts#L97-L134. But this doesn't have support for custom routes. We have discussed adding support for custom routes in HTTPReceiver (the default receiver since [email protected]). I imagine that would be when we investigate sharing that code with SocketModeReceiver.
@stevengill We at Salesforce are also seeing this limitation as well. I think this would be a great feature as it would be nice to use socket mode to develop locally and handle custom express routes as it's a requirement for my use case. Was pointed to search this repo as this was a question a brought up during an internal Slack session with Bear Douglas.
What would be the alternative? Would we have to use the node slack sdk directly (@slack/socket-mode, @slack/web-api, @slack/events-api) and set up express manually?
Hey @lranches-sfdo,
Yeah I definitely see the value in custom routes. Especially for this usecase of using socketMode for development but still support some custom routes. I've created an issue to specifically track this issue over at https://github.com/slackapi/bolt-js/issues/866
An alternative would be to use those libraries, but it is a good amount of work to setup. Also @slack/events-api has been deprecated in favor of Bolt.
Most helpful comment
Hey @lranches-sfdo,
Yeah I definitely see the value in custom routes. Especially for this usecase of using socketMode for development but still support some custom routes. I've created an issue to specifically track this issue over at https://github.com/slackapi/bolt-js/issues/866
An alternative would be to use those libraries, but it is a good amount of work to setup. Also
@slack/events-apihas been deprecated in favor of Bolt.