Improve your team’s social life with Robi, the Coffee Robot
Tags: node, python
Published: 2024-04-09 09:20:29

The Short Story of a Coffee-meeting Robot, initially designed to alleviate the effects of COVID-19, now serves as a team-building tool, bringing together colleagues who might never have spoken otherwise.

**Company Coffee Breaks**

Coffee breaks with colleagues remain an important part of office life to this day. People gather around the coffee machine, sharing stories from both professional and personal perspectives. These spontaneously organized social conversations were an elemental part of the workplace until a pandemic sent everyone home.

**Anyone Home?**

It's probably unnecessary to delve deeply into the period during COVID-19, but perhaps everyone felt a bit more distant from their friends and colleagues. When everyone was working from home, even a single meeting became a pleasant social experience.
There was a need for colleagues to continue their friendly conversations. Plus joining the organization as a new colleague was especially hard during this Covid-stricken period as there was no opportunity to meet their new coworkers in person.
To strengthen social connections, we found a solution in a Slack bot inspired by spontaneous conversations around the coffee machine.

**Robi**

As we'll call him from now on, Robi started as a simple bot built with Python. Our basic idea was to gather people in a separate Slack channel who were willing to chat with their colleagues in some organized form during the week, naturally within the framework of online meetings during the pandemic.
In the channel, using various commands, you could join the coffee break or pause your participation in it, which might be necessary in case of vacation. And on Mondays, Robi would randomly divide people into pairs, opening up private group chats for them on Slack. After that, it was up to the participants to coordinate a suitable time for their coffee break.



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ztrvlj4rktlid44xvng3.png)
"Hey there, you've been chosen this week! Enjoy your coffee!"


**Not Just Friends**

One significant change from the personal conversations around the coffee machine was that not only friends and acquaintances but also colleagues who may have never spoken to each other for various reasons, got the chance to spend half an hour getting to know each other.
It was also important, especially for new colleagues, to feel like part of the organization, and to get to know those they might not work with every single day.
The coffee breaks started with about 30 participants. However, we had to adjust the logic of the picking system later on because the random method surprisingly often paired the same people together multiple times in a row. The new method considered the participants' "coffee history" (how many times they had already had coffee with each other).

**Not Just Coffee**

During these coffee breaks, it's not necessary to drink coffee. A tea or any refreshing beverage is suitable for engaging in a pleasant conversation for about half an hour.
The initial success of the coffee breaks was also attributed to the fact that participants could choose a gift package before the first pairing. We aimed to encourage as many people as possible to participate in community building. The following packages were available to choose from:

- Nespresso capsule package
- Dolce Gusto capsule package
- Whole bean coffee package
- Ground coffee package
- Tea package

Similar packages were made available to the participants multiple times.

**Initial Successes and Limitations**

The coffee breaks initially garnered great success. Many joined to chat with their colleagues stuck at home, meet new coworkers, or simply unwind.



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8sae3yf15wy2t351lt8c.png)
"Drawing in an hour! 15 pairs notified."

However, this enthusiasm dwindled towards the end of the year. As the coffee break regulars went on holiday leave, upon their return, they were more focused on work than coffee breaks. With the easing of restrictions, people were free to return to the office, and self-organized groups once again gathered around the coffee machine.

Moreover, during the coffee breaks, pairs often consisted of individuals who found it challenging to initiate a conversation.

Moving From a Covid Solution to Sustainable Team Building
After several years of hiatus, Robi has returned in a new form. Instead of pairs, now there's the opportunity to chat in groups of three. The goal is no longer solving the isolation caused by Covid, but rather fostering long-lasting and engaging team building within the organization, where anyone can participate at any time.

With the three-person groups, the half-hour coffee breaks just "fly by". There's always a topic to discuss, and there's a smaller chance of less talkative individuals ending up in the same group.

**Current Workflow**

Robi now operates on Node.js, utilizing the new Slack API.
As for the pairing algorithm, we've experimented with various approaches. Initially, we tackled the problem by conceptualizing the participants as a graph. Each player participating in the coffee breaks during the current week represents a vertex in the graph, interconnected by weighted edges. The weights on the edges are positive integers representing the number of previous coffee breaks between the two players. For example, if Alice and Bob have had coffee together three times in the past, there will be an edge with weight 3 between the vertices representing Alice and Bob in the graph.

Translating the coffee break problem into a graph-theoretical problem allowed us to explore different algorithms. One of the algorithms we tried was the Edmonds-Karp algorithm (https://en.wikipedia.org/wiki/Edmonds%E2%80%93Karp_algorithm), which is a variant of the Ford-Fulkerson algorithm. Normally, the Edmonds-Karp algorithm searches for the maximum flow in the graph, but with modifications, it can also find minimal matchings. The time complexity of the algorithm is O(V^2*E), where V is the number of vertices and E is the number of edges in the graph.

While various complex graph operations could solve the problem of perfect grouping, translating them into Node.js proved to be quite challenging. Therefore, we currently employ a heuristic-based approach. We randomly assign groups of three and observe the number of times they had coffee together. We repeat this process 10,000 times and select the pairings with the fewest meetings. This method runs in under 10 seconds and yields favorable results.

With the latest update, we've implemented a feature to reduce the likelihood of managers, who typically communicate with each other frequently, being paired together. Instead, they're encouraged to spend time with other team members.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zvzmf949qwxgpyk2hrgl.png)
"The pairing has begun! Groups notified. Enjoy your coffee!"

**Summary**

Robi can be an efficient tool for organizational life, helping colleagues get to know each other better, including those with whom they may not have interacted much before. Additionally, for new hires, it can be immensely beneficial in making them feel like part of the larger team at the organizational level.

This article was written by **Peter Angeli**, Software Engineer at [Danubius IT Solutions.](https://danubius.io/en)