
Discover how to build a Slack bot to automate tasks in your business, from billing to coordinating with developers, project managers, and clients.
The Atom code editor is no longer available.
I now use Visual Studio Code: https://code.visualstudio.com/
Set up a Node.js server using Express to accept incoming post requests to the purchase slash command, and run it on port 9647.
Expose your local server with ngrok on port 9647 using a secure temporary URL for Slack integration, and configure express with body-parser to handle post requests.
Master using git to manage a Slack bot project from slash commands to commits and pushes, and apply Slack's message builder to craft a meaningful json reply.
Create a Slack bot in your app by adding a bot user, obtaining a bot OAuth access token, and using the Slack API to automate messages.
Create dynamic Slack messages by formatting purchase notifications to the CEO, using the message builder, template strings, and user IDs for clickable references, and prepare authorization actions.
Learn how to implement interactive Slack messages with attachments and buttons to route purchase approvals to a CEO, using post message calls and attachments formatted as json.
Explore a Slack bot workflow that notifies the CEO for purchase approvals, then sends direct feedback to the requester based on approval or denial.
Leverage Firebase as the memory of your Slack bot by storing purchase data with unique keys, routing through the CEO, and retrieving details later using those keys.
Add a timestamp to each purchase request with moment.js, saving moment.valueOf() on creation so the Slack bot can track time and prompt the CEO after four hours if no decision.
Record the CEO's decision in the Slack bot's memory by updating the Firebase database on button clicks, using the update method to set the purchase request decision in real time.
Review and clean up code for a Slack bot; rename boolean to approved or denied, use update to preserve data, and run a cron job to process purchase requests.
Iterate over a firebase object with Object.keys to pull purchase request keys and values, delete nodes to reset data, and access timestamp, user ID, item, and decision.
Analyze each purchase request to compute minutes since creation and determine whether a decision exists, log the timestamp and decision (approved, denied, or pending) for CEO reminders.
Build a Slack bot that gathers purchase requests from Firebase, flags undecided items after 94 minutes, and sends the CEO a single direct message with markdown-formatted attachments.
Move this Slack bot from local development to production on a DigitalOcean droplet, using nginx reverse proxy and https certs to ensure a secure, persistent deployment.
Note: Slack has been updated quite a lot since this course was created. My latest course How to build an OpenAI bot for Slack uses the latest APIs for both Firebase and Slack.
There are so many aspects of businesses that can be automated using Slack.
What does it mean to automate a task?
Imagine being able to take a process in your business, and be able to get a bot to not only do it for you, but also do it perfectly every time. Not to mention your bot can be working 24/7, often perform tasks much faster than a human, and check on updates to systems every few seconds instead of hours or days. aka. the perfect employee.
What sort of tasks can be automated in Slack?
Almost anything you can think of. You're only limited by your creativity.
Say a client wants to know their balance on their account. They could email you, and then you reply. Or you could give them a slash command to retrieve their balance whenever they want.
Maybe a developer needs to log time they've worked. They could go into an accountancy system and manually enter that time, and then send a message to a project manager to let them they've finished their task. Or... you could give that developer a single custom slash command that will perform all those tasks for them.
So what are we going to learn in this course?
Let's say you have a company where employees can submit purchase requests for things they might want. They would normally fill out some form, give it to a secretary, who would then take it to the CEO to make a decision on. That secretary then needs to give that feedback to the employee who requested the purchase.
The secretary will also monitor all the purchase requests, so that if the CEO has forgotten to make a decision on one of them, that secretary will remind the CEO.
In this course we're essentially going to code up this entire flow, primarily by turning the human secretary into a Slack bot. So that the only human beings who will use the system is the CEO and the employee making the purchase request.
Pretty amazing right?