Sheldon: a team routine automation bot

Maxim Lanin
AvitoTech
Published in
5 min readMar 22, 2022

Before the Сovid-19, when we all worked from the office, life was simple and sweet. Everyone was physically available, sitting behind the next office desk, we could always have a quick chat to check out the progress of something or give a reminder. Team activities were offline, it was easy to get together at the blackboard or gather in a meeting room. The team TV played sprint statistics, product metrics, OKR results.

When the pandemic hit, we switched to full-time remote work, and life became different. It became more challenging. And not only for the manager, who had to restructure all their interaction with the team, but also for the team members. Multiple previously unknown routines emerged:

● Constantly monitoring the progress on different boards.

● Reminding about stand-ups, tasks and PRs.

● Bringing the team together on Zoom for meetings.

Processes and work in general began to lose transparency. It became clear that something had to be done about it.

We need more bots

With the advent of remote work, Slack became virtually the only meeting place in addition to Zoom. We came up with the idea to write a bot that will regularly collect various statistics and upload these to the team chat.

No sooner said than done. Over the weekend, a simple bot was written, proudly named Sheldon after the Big Bang Theory character and featuring a corresponding avatar.

Daily status

At that time, Sheldon could only send a daily notification to the chat with a list showing the following:

● what tasks are stuck;

● what PRs are currently open and for what tasks;

● what critical bugs were found in the backlog — we have a procedure for fixing these.

Another nice thing was that in the notifications sent out every morning, the author or the one who was expected to pay attention was tagged. So the right people received notifications, and I got rid of the routine need to send out reminders.

Later, we added to Sheldon’s messages information about those who were going on vacation in the coming days and from what date, or those who were away on vacations and when they were expected to be back. At that point, a chat post looked like this:

Sheldon gets the information from Jira, Stash, and our internal portal.

Weekly report

The experiment was a success and we began to develop Sheldon. The next step was to send once per iteration an update on the general progress to the goals and task statistics. To do this, we had to train Sheldon to build a progress bar and charts.

OKR progress. Unfortunately, Slack is unable to display rich graphics. We needed a solution to display the progress on OKRs. The idea was adopted from here — display the progress bar as 10 ⬜ and 🟦 characters, where the former represents the progress bar itself, and the latter one — the actual progress.

Thus, if we have an OKR epic with 100 tasks and 20 of those are completed, we have the following sequence — 🟦 🟦 ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ (20/100). The source code adapted to our use case is available here.

Knowing which of the epics are responsible for OKR, one can easily find out and display progress as a percentage completed. We know this is not how goal progress is calculated in the real world, but that was the only automated option that could be implemented at the time.

Task statistics. Looking constantly at a cumulative chart, trying to calculate statistics, is a boring thing. Besides, we wanted to give access to such data to the entire team. Therefore, we decided to add graphs for new/completed tasks and bugs to the bot message.

This was a greater challenge — that was a graphic asset, and the only more or less working option to attach a picture to a bot message was adding a link to a file available via http. At that time, we didn’t have a working solution for adding a picture to a persistent storage, and we needed a workaround.

As a result, an http handler was developed that generated a chart in png based on an array of data points received via a get request. The link itself was generated at the time of sending the message after collecting the data points from the statistics. Thus, we got rid of the storage and were able to build all kinds of charts in the runtime. The only limitation is the number of data points we could display, because get is limited to 2048 characters. Source code is available here.

The result was a message that came every Monday:

More automation

Simply showing the status and sending reminders about stuck tasks is good, but what if we add a button to close those? No sooner said than done. Sheldon learned how to close PRs with all tests passed and approval granted, as well as tasks in which all PRs were merged.

Gradually, Sheldon began spilling out. It was added to the team’s general product support chat to systematize requests. The bot learned how to change team members on duty and invite everyone interested to our demos.

Sheldon can much more that that:

  1. It automates the on-duty process. It assigns a team member on duty, reminds to answer a question in the channel, and reminds you when you are on duty.
  2. It reminds you to close any open cases before you take vacations.
  3. It reminds the team about the upcoming demo so they don’t forget to prepare.

Results

Other teams learned about the bot, and from a pet project it transformed into a large-scale one. We had to refactor it. The code was subdivided into modules, modules into blocks, a simple setup mechanism was added. As a result, after massive advertising in general channels, another ten teams adopted Sheldon. Thus, Sheldon became a full-fledged team member.

--

--