Cloudreach Blog

Catch the latest stuff

Mad Expert Bot – A GCP Chatbot on Slack

Team small but mighty 5th September 2017
Mad Expert Bot Cloudreach Hackathon

Hackathon theme and rules

In Cloudreach we are very keen to not only support our customers on their digital transformations, but also to use our knowledge and expertise in order to contribute to society, and create something new that improves other people’s lives. One of the ways we do that is through the .create() hackathon. Similar to Daniel’s post on ‘Attending a hackathon when you can’t hack’, we wanted to share our experiences of taking part in this event. You may be wondering, Hackathon number 3, what’s the topic?

Google Cloud Platform (GCP): Ask Me Anything

This time around, we had to create a service which could answer questions related to technical issues we face every day. Another requirement was that our creation had to find information related to different cloud environments by making use of public datasets available on BigQuery. So basically we decided to create a bot that listens for questions in a certain format and tries to find the best answers from Stackoverflow. That is how Mad Expert Bot was born.

Our team

Good things come in small packages. As a team of 2 Cloud System Developers, we have previous experience in various migration and implementation projects in AWS and Azure including containers and serverless applications, but none in GCP. We used this as an advantage to push us to  learn faster and identify the key services that best suited our project.

Mad Expert Bot – the inception

The first choice we had to make when creating the bot on GCP was whether we were creating an emailbot that answers questions in the same email thread or a chatbot that answers your questions via IM. We finally decided on a Slack chatbot, given that the questions would be of technical matter and Slack is widely used across Cloudreach among the techie teams.

So we know that the user is going to ask their question through an Instant Message on Slack and that they are going to get a text reply back. But who is going to understand the question and where is it going to take the information to form a response?

To answer the first question we tried two platforms: API.AI and Botkit. We found API.AI to be really easy to setup and especially easy to integrate with Google Cloud Functions (Google’s Serverless offering) and GCP in general. Botkit, on the other hand, is less intelligent but more customizable in terms of integrating it with Slack, our platform of choice.

And now to the second question, it was quite straightforward: the information to reply back to the user was going to be taken from Stack Overflow database of posts, which is available on GCP BigQuery Big Data offering as a ready-to-use dataset.

We said before that Botkit was a bit more customisable, and after a few trial and error cases integrating both API.AI and Botkit with GCP Big Query, we decided on Botkit. This was largely due to the possibility of managing timeouts and responses that take longer than usual, which unfortunately we were not able to do on API.AI due to a hard timeout of 5 seconds on webhooks.

The tool stack was laid out.

Mad Expert Bot – Creating a GCP Chatbot

Even though our Mad Expert  Bot is able to understand different ways of expressing a question, the user must be pretty constant in the pattern. Examples:

  • How can I solve error 500 Elastic Load Balancer on AWS?
  • How to modify RBAC permissions on Azure?
  • How would I switch projects on GCP?

Below you can find an example response from the bot.

Mad Expert Bot example Cloudreach GCP

Mad Expert Bot – Inner workings

Below we show the components of our solution and the communication between them.

Mad Expert Bot - Inner workings Cloudreach GCP

The brains behind the beauty of the Mad Expert Bot

The most critical part of the solution was defining the logic to find the posts that are the best match for the question asked. To do that we looked at the stackoverflow database and designed a mechanism to filter and sort through the multitude of posts we can find in stackoverflow for a simple question. This is the process:

  1. The first filter applied uses the tags of the stackoverflow posts about the platform. So the tags should contain ‘aws’ or ‘azure’.
  2. Question Rank = First ranking is calculated, the question fit rank. First we check if the question title contains exactly the search phase and assign a rank of 100 if that’s the case.Then we add the number of the keywords the question contains
  3. Answer Rank = 1 if the question has an accepted answer, otherwise is 0
  4. Answer Score = number of votes the accepted answer has.
  5. Order the results first by question rank, then by answer rank and then by answer score.
  6. Top 5 results are sent back to the application

We split the processing logic between the NodeJS application and Big Query service and we achieved a ~6s response time.

Mad Expert Bot – What we learned

First and foremost, we had a great time doing this hackathon! We were able to try GCP – a cloud environment totally new to us, and learn and develop our skills by doing so.

On the tech side, we learned that GCP offers a really interesting toolset to deploy bots, containers and Big Data applications.

Another key takeway is that trial and error is not the best approach for a hackathon (our final solution had to be made in under 8 hours from the initial 48 hour time due to flaws on our first design!). Next time, we’ll sure take more time to design and then follow that design through all the way to the delivery.

 

 

For more hackathon related posts, click here

What will you create?