Should you build a Slack bot? Building one saved our future sprints

Have you ever tried to improve or automate a process in your team or organization? Slack bots could be an easy and quick way to do it.
Let me tell you how my team at Infobip built an internal Slack bot, how to build your own using Node.js, PostgreSQL, …

Have you ever tried to improve or automate a process in your team or organization? Slack bots could be an easy and quick way to do it.
Let me tell you how my team at Infobip built an internal Slack bot, how to build your own using Node.js, PostgreSQL, and Slack bolt, how to integrate it into your workspace, as well as how to deploy it on Azure Cloud.



From Bottleneck to Bot

My team uses 2-week sprints, and each task gets code reviewed by at least one person from our team. The code review process turned out to be a bottleneck. We didn’t have an explicit way of determining the code reviewer for our tasks.

Our original idea was that anyone who has free time will check out the Jira code review column and review some tasks. When that approach didn’t work, we agreed among ourselves on who will review which task. However, we chose the person we were closest to, leading to inequality in the workload.

We wanted to find - and needed - a solution that included making the code review Jira column no longer a bottleneck for us while focusing on making the number of code reviewers equal per sprint.

How about building a Slack bot?

We can build it to display the name of the person who will code review the task. The bot would select a person using the round-robin arrangement. Another idea was to create a special application for that, but this was a simpler approach because we already use Slack for our internal communication and meetings.



Our Code Review Picker Bot

To use it, we would send a slack message in our private channel to the bot. It would respond with the name of your code reviewer.

All it takes to add the app to your private Slack channel is to use the „Add apps to this channel” command.

I’ve used Node.js along with Slack bolt framework and PostgreSQL for data storage. I picked Azure for deployment because at Infobip, each of us has a personal monthly budget for the platform. Azure Cloud was overwhelming at first because of the many options it offers. But it soon became one of my favorite deployment platforms because it’s easy to understand and use.



Create a Slack App? Easy and Fun

Learning how to create the Slack app was easy and fun because of detailed Slack documentation. Slack has many tutorials on how to get your bot up and running, which you can check out here: https://api.slack.com/start/building/bolt-js

To create an app, visit the apps page on Slack: https://api.slack.com/apps.

Create a Slack app

Go to Settings > Basic Information tab and save the Singing secret from your App Credentials. Install the app to your workspace to get the OAuth token. After that, go to OAuth & Permissions screen and save the Bot User OAuth Token. On the Bot Token Scopes page, select the scopes you need. I’ve selected the chat:write and users:read scopes to start.

After creating the Slack app, go to portal.azure.com and create a new App Service. I’ve picked Node as the Runtime stack and Windows OS. After you create the service, save the Slack token and Slack bot token as environment variables in the Configuration tab on the Settings slots of your app.

Go to the Deployment Center on the Azure Portal and pick the deployment option that best suits you. I went with the Local Git option. Clone the repository and initialize your project using the npm init command. 

Install the @slack/bolt package: npm i @slack/bolt. Push the code to deploy the changes:

Go back to the Slack API bot setup and visit the Event Subscriptions page to enable events. I’ve subscribed my bot to the message.groups event to receive an event payload whenever a new message is posted in a private channel to which the bot is added. After turning on the toggle switch to enable events, enter your Request URL which is available on the Overview page on the Azure portal. It should look like https://azure-app-url/slack/events. If you see a green check mark after entering the URL you are all set and you can subscribe your bot to the events.

After subscribing to events, I’ve used the message function to attach a listener to messages that contain the word review.

I stored the information about the code reviewers and registered channels in a PostgreSQL database hosted on Azure using Sequelize as an ORM.

For debugging the application, visit the Monitoring slot on the Azure portal, and on the App Service logs tab turn on Application Logging to connect to the Log stream.

It’s best to first create a test private channel to test the bot and try out all options that the Slack bolt framework offers.

That’s it. Have fun building your bot. Once we started using the Slack bot in our Infobip team, the code review was no longer a bottleneck inside the sprint and after a while, we completely forgot that it used to be a problem for us.



Another Example: Metrics For Human Emotions

Another use case for which we used a Slack bot is to collect mood data within the team. Working from home made it challenging for us to check up on each other. We heard of the Niko-Niko agile method, which is a simple calendar where everyone states their mood daily.

Everyone can express their mood as good, bad or neutral. The Slack bot sends a message each day to our private channel and saves our mood to the calendar.

It can also make a useful checkup on 1 on 1 meetings with your manager on things that can improve. Everyone should feel safe to express their mood honestly and be aware that their manager is there to help.

The data is represented for each team per month. You can track the mood board calendar showing each person’s mood for the day and charts per team or an individual showing the trend and the summary. I developed it using .Net with Blazor and Chart.js extension for Blazor.

Mood metricsPhoto by wu yi on Unsplash

Have you tried using a Slack bot to improve some of your team or organization processes? I would love to hear your ideas and thoughts about Slack bot implementation.


Print Share Comment Cite Upload Translate
APA
Nejra | Sciencx (2024-03-28T22:09:40+00:00) » Should you build a Slack bot? Building one saved our future sprints. Retrieved from https://www.scien.cx/2021/07/28/should-you-build-a-slack-bot-building-one-saved-our-future-sprints/.
MLA
" » Should you build a Slack bot? Building one saved our future sprints." Nejra | Sciencx - Wednesday July 28, 2021, https://www.scien.cx/2021/07/28/should-you-build-a-slack-bot-building-one-saved-our-future-sprints/
HARVARD
Nejra | Sciencx Wednesday July 28, 2021 » Should you build a Slack bot? Building one saved our future sprints., viewed 2024-03-28T22:09:40+00:00,<https://www.scien.cx/2021/07/28/should-you-build-a-slack-bot-building-one-saved-our-future-sprints/>
VANCOUVER
Nejra | Sciencx - » Should you build a Slack bot? Building one saved our future sprints. [Internet]. [Accessed 2024-03-28T22:09:40+00:00]. Available from: https://www.scien.cx/2021/07/28/should-you-build-a-slack-bot-building-one-saved-our-future-sprints/
CHICAGO
" » Should you build a Slack bot? Building one saved our future sprints." Nejra | Sciencx - Accessed 2024-03-28T22:09:40+00:00. https://www.scien.cx/2021/07/28/should-you-build-a-slack-bot-building-one-saved-our-future-sprints/
IEEE
" » Should you build a Slack bot? Building one saved our future sprints." Nejra | Sciencx [Online]. Available: https://www.scien.cx/2021/07/28/should-you-build-a-slack-bot-building-one-saved-our-future-sprints/. [Accessed: 2024-03-28T22:09:40+00:00]
rf:citation
» Should you build a Slack bot? Building one saved our future sprints | Nejra | Sciencx | https://www.scien.cx/2021/07/28/should-you-build-a-slack-bot-building-one-saved-our-future-sprints/ | 2024-03-28T22:09:40+00:00
https://github.com/addpipe/simple-recorderjs-demo