Creating a Slack bot from scratch during my Mito.ai summer internship

Karen Maria Nyvoll
Strise
Published in
8 min readAug 6, 2018

My name is Karen Nyvoll, and I’m on my third year of my Computer Science degree at NTNU in Norway. Currently, I am on my last day as a summer intern at Mito.ai. It has been four incredible weeks from start to finish! I have learned so much and I feel very lucky to have had so amazing colleagues during my internship. Founded in 2016, Mito.ai is an AI company based in Trondheim, Norway, that specializes in analyzing vast amounts of articles and news online. The results are used to create a graph representing the media landscape of the world(!). To ensure uptime and performance on a system of this scale, meaningful and reliable health metrics (like queue size, API latency, etc.) need to be available to everyone at Mito.ai with zero configuration. Since Mito.ai is already using Slack as their primary communications channel, making these metrics available in Slack seemed like an obvious choice; it turned out to be a really interesting and fun project!

The main task of the bot is to monitor the state of Mito’s internal system, Omni, hence the name OmniBot. It will check the status of the queue every five minutes. When the queue gets too high, an incident object should be created and a push message should be sent to a specific channel in Slack. Users can then, through a button interface, assign themselves as “fixers” and mark the incident as “fixed”. The incident will be resolved when the queue is back to normal levels, in which case all users will be notified. In addition to the push messages, the bot also has three slash command functionalities.

Queue push message in action
The three available slash commands
The omnihello command

The “omnihello” command is mostly added for fun, but has been very useful for checking end-to-end status while testing. It replies with a simple greeting message. “Omniml” is short for “omni machine learning”. The command replies with an article, its suggested category or entity, and a button interface where the user can decide the relevance of the specific article or entity in relation to the article. An entity is in this case a node in the information graph that Mito.ai creates, as mentioned in the introduction. The purpose of this command is to annotate the articles and train the machine learning models that Mito.ai uses for text analyzation. If a specific category or entity needs more content, Mito.ai can push articles that need to be annotated on their end. The final command, “omnistatus”, informs the user of the current status of the queue. It can, among other things, be used in the middle of an incident, if the fixers don’t want to wait for five minutes to check the most recent status of the queue. The architecture of the bot is designed to be modifiable, so both new push messages and new slash commands can be added later if necessary.

Machine learning command in action

The first few days of the internship were simply used to set up the correct environment. I was instructed to use WebStorm, an IDE I hadn’t used before, and write code in JavaScript, which also was new to me. It was a little difficult to set everything up, but I got a lot of help, so everything went very smoothly. During the first week we also had a meeting where all the summer interns and new hires were given a run-down of the current system. It was very interesting to see how a professional AI company structures itself, business and technology wise, and how many resources are needed to run such a massive system. I’m new, but I’ve noticed, Mito.ai has a very good work environment. It’s okay to ask dumb questions here, to ask for help, and to make mistakes. This has been crucial in making me feel as welcome and safe here as I have, and in making the project as interesting and fun as it has been!

Overview of the file structure

In terms of architecture, the bot was divided into two main structures. The middleware functions, that consecutively went through input made by slash commands on Slack, and the push message functions, that independently … pushed messages. All input to the bot was done by sending JSON objects to the bot server, while all output from the bot was done either by replying with JSON on that request, or sending messages to the webhooks available on Slack. The bot gathered information about the internal state of the analyzation system by sending GraphQL queries wrapped as JSON objects to a GraphQL endpoint for Omni, and reading the feedback. Mutations for sending feedback to the internal system were sent the same way.

My journey in learning JavaScript went mostly all right, considering how liberal the language is. Navigating the unwritten code-conventions, e.g. when to use “let”, “const”, or “var”, was a bit tedious — but I got the hang of it after a while! I think it can be agreed that learning a new coding language can be like that sometimes. Finding the right package for the job really increases the learning curve to the JavaScript ecosystem and I’ve learned so much! Not only about the technical aspects of making a bot, but also about what it is like working in a technology company, about how one can work individually but cooperate on certain things as well. Mito.ai has an extremely good environment where asking for help and cooperating never was an issue. It’s been exciting, fun, and frankly super uplifting to see that this is the industry I’m currently educating myself into.

Test files

While developing the bot, some frameworks were used to make sure the code had the right qualities. Jest was used as a testing framework and had testing files for all testable functions in a “_tests_” folder. Prettier was also used, for reformatting the code according to a given standard — also known as “prettifying”. Both Jest and Prettier were run before every commit. When it was time to merge branches on git I created a pull request, and my mentor at Mito.ai, Christian Budde Christensen, looked through it and gave me feedback. Before a pull request could be merged, it was approved by him and went through testing with Jenkins.

Christian has been of great importance to me and I’m super grateful for all of the help and guidance I’ve received! A lot of the time when I would ask questions I was given hints, tips, and resources instead of simple answers, which has helped me learn a lot. Additionally, I was encouraged to make decisions on my own, which, for someone like me who is a little bit shy, has been very helpful in making me more independent and confident of my own skills! Every morning those of us working in tech would have a “stand-up” where we would go through what we had done since the last time and what the plan for today was. Before the first stand-up I was pretty scared, I thought it was some kind of company comedy routine — and I was not prepared for that. Luckily it wasn’t. We would also have weekly meetings (Mitings), where we among other things would go through Mito’s three core values:

1) You are Mito: make decisions.

2) Expand your comfort zone: if something seems smart but uncomfortable — do it.

3) Advantage Mito: unexpected events will happen. Make it to our advantage.

For every category we would list contenders, discuss and praise, and then decide on victor(s). I was written up a couple of times, and that was always very exciting! We’ve never had anything like this when I’ve worked in groups at my university, but I think I’ll start insisting on having something similar. It really brought a positive vibe into all of the work that was done at Mito.ai. I think I have a lot to learn from these core values, not only as a employee and a student, but as a person as well. During my stay at Mito.ai, we also had a summer theme party with a cascading theme. Originally, in celebration of the world cup, we were going to play football and eat at a Russian restaurant, but due to a lot of different circumstances we ended up with mini golf and an Indian restaurant instead. It was super fun, and helped me feel all the more welcome at Mito.ai!

Not football, but mini golf. Go team!

All in all, this internship at Mito.ai has been absolutely amazing. It’s been fun and intriguing to see the bot slowly and steadily improve and — even though there wasn’t as much improvement every single day — I’ve learned something valuable and gotten more confidence in myself with each passing day. I have felt safe and in good hands while working here and I’ve known that if I’m stuck or don’t understand something, it’s perfectly safe to ask for help or reach out. I’ve had a great mentor that has encouraged me to make decisions on my own and helped me learn how it’s done in a company both in technical terms and teamwork-wise. It’s also been good to hear that even in the professional world it’s still possible to have trouble with too many ‘ifs’ in a function! There is so much of this internship that I’ll bring with me in my future endeavors, especially when it comes to the Mito core values. I’ll do my best to keep doing smart, uncomfortable things. I feel incredibly lucky to have had such creative, intelligent and wonderful colleagues and, even though I’m leaving, I truly hope the bot that I made will be of good use to them.

Mito! At Indian restaurant

I can’t imagine a better possible summer internship, thank you so much Mito.ai for this opportunity!

--

--