This application proxies Slack slash-command requests to Crossway's English Standard Version REST API.
When a Slack user types /esv Romans 1
, Slack will post a request to your web application. This application will
then make a GET request to api.esv.org to get the desired text, and return it back to Slack to be posted in a channel.
SlackESV can certainly be deployed as a self-executing jarfile to any server with which you are familiar. But it is tested primarily with Heroku, and is quite easy to get running on Heroku by following these steps.
- Obtain an application key from api.esv.org, which will require manual approval from their staff. This key is what will be used to identify your requests. You should also be aware of their conditions of usage.
- Set up your slash command for your Slack organization. Go to https://api.slack.com/apps, and create a new app. Be aware that the URL field will need to be changed once you get a url from Heroku. Also make note of the generated Token field, which will be used in the next step. Set an icon if you wish, as well as the autocomplete.
- Launch a heroku instance Use your ESV application key that you obtained in step #1, and the slack token you obtained in #2, to launch the instance.
- Find the domain of your newly launched application on the Settings page for your app. Go back to your Slack slash command configuration and set the URL field with your heroku app's domain.
- Heroku free dynos fall asleep after an hour of idle time. The wake-up time is a big deal, and will result in Slack timeouts the first request after an idle period of time. You can use any sort of service to keep your dyno alive. I had success with UptimeRobot. You can create a monitor with your Heroku URL, followed by /health?echo=whateverYouWant. It is a good idea to also set up an email notification, so that if there are problems with your service you'll be notified.
That's it! You should be good to go!