This project is a Node.js application that automates Slack using the Bolt framework. The application allows users to personalize Slack by using commands in Slack chat to perform tasks such as bug tracking, scheduling, and content storage.
We need to first configure your slack api. Visit https://api.slack.com/, login and then create a new app. Navigate to manage apps and then to your newly created app.
SIGNING_SECRET
: at the default page, grab the signing secretBOT_ACCESS_TOKEN
: navigate to OAUTH & Permissions and grab the Bot User OAuth Token.REDIS_URL
: visit upstash and start a free redis instance, grab the main url.PSQL_URL
: lastly choose a cloud database that supports postgres instances, and grab the main url. I chose supabase.
Configure this project by setting the following environment variables:
BOT_ACCESS_TOKEN= The Slack bot token
SIGNING_SECRET= Slack signature
PORT= Main application port
REDIS_URL= Redis cloud url
PSQL_URL= Postgres Host Url
Once the environment variables are set, you will need to have Node.js and npm installed on your machine. You can install the dependencies and start the application by running the following commands:
npm install
npm run start
In order for your slack to reach this running app, the local endpoint needs to be forwarded and exposed to the web using ngrok. Follow the intructions until usage and run:
ngrok http 3000
Copy the "Forwarding" url, ex: https://7d0b-173-52-201-90.ngrok.io, to use in the next step.
-
Go back to you slack api page and navigate to 'Interactivity & Shortcuts' on the side menu:
In the request url input field, paste your link with /slack/events added to the end of it, ex: https://7d0b-173-52-201-90.ngrok.io/slack/events. Click save.
-
Next, navigate to 'Slash Commands' and create a new command.
Here put the same link we used for interactivity in the request url field. Give the command a name and description. Click save.
-
Finally, with the same link, navigate to 'Event Subscriptions':
Paste the link in the request url field. Save changes.
At the point of running this app, permission errors and missing scope errors will prompt. In your slack api website where we got our bot token at 'OAuth & Permissions' navigate down to the 'Scopes' section of the page and add all missing scopes there. Save changes.
The application can be used in Slack by sending commands in the chat. The following commands are supported:
/track help
: List all commands for bug tracking./track new
: Start a new sprint to track a bug./track sprints
: Open list of all sprints.
- Node.js (https://nodejs.org/)
- npm (https://www.npmjs.com/)
- Slack API (https://api.slack.com/)
- Bolt framework (https://slack.dev/bolt/)
- Ngrok (https://ngrok.com/)