The folks at Botkit have done an amazing job at building a framework for (Slack) bots applications. They have included an example of creating a Slack app that can be installed with just an "Add to Slack" button, as well as an adapter allowing to use MongoDB for storage.
However, the example used Botkit's webserver to manage requests such as authentication, but also serving webpages. Instead, I wanted to use Express.
-
Serves webpages through standard express routes
app/routes/routes.js
-
Uses Monk as MongoDB driver
-
Includes by default the three Botkit collections : Teams, Users, and Channels
First, create a Slack app. You'll get your app ID and Secret, and you'll be able to enter authentication redirect URL. To be able to use the app both on a local machine and in cloud hosting, enter two URLs:
http://localhost:5000/
http://yourwebsite.com/
Then, you need to set up several environment variables before using this app.
- For local deployment
Create a .env file at the root of the project with the following infos (you can modify and rename the existing .env-example file:
SLACK_ID=your.id
SLACK_SECRET=yourslacksecret
SLACK_REDIRECT=http://localhost:5000/
PORT=5000
- For Heroku deployment
You need to add from the Heroku dashboard the SLACK_ID, SLACK_SECRET and SLACK_REDIRECT (set it to your website root).
You can use MongoLab add-on to add Mongo storage, they have a free tier.
Shared under MIT licence