【GMOリサーチではエンジニアを募集中です】採用情報はこちら!

Slack Bots at GMO Research

Slack Bots at GMO Research

(This article is an English version of the article below.)

Hiya! My name is Antonio, and I have been working in the System Department at GMO Research for a bit longer than two years.

I was born in Mexico, and I moved to Japan in 2018 shortly after finishing my master’s program in Europe. I have been working for GMO Research since then.

A certain global pandemic happened, and I was granted the chance to work remotely from my home country for the past 5 months, with a timezone difference of 14 hours. 

For this blog entry, I would like to talk a little bit about some of the tools that make our work easier in the System Department at GMO Research, particularly, the Slack bots that have been customly made for our needs. 

Slack is widely known to be used as a very handy communication tool for teams in an organization, and it has many useful features that boosts a team’s productivity. Below is the definition from the official website:

Slack is a channel-based messaging platform. With Slack, people can work together more effectively, connect all their software tools and services, and find the information they need to do their best work — all within a secure, enterprise-grade environment.

The list of messaging platform tools is endless, and Slack is just one of these tools.  What makes Slack stand out from other tools is its support for third-party integrations, and its very friendly API that allows users to create their own plugins, and even bots. 

What is a bot?

A bot is simply a piece of software that runs in the background that may respond to external events and triggers, and perform an action towards a goal. Bots may be used for countless scenarios, and the right bot may increase the productivity of a team considerably. 

In GMO Research, there are certain tasks that tend to be repetitive and simple to perform, and precisely such a task would be a perfect candidate for automation through a bot or app. 

Bots made for and by GMO Research

In the following section, I will describe some of the solutions that have been reached by implementing our own customized bots, or by adapting existing integrations.

slack-translate-bot

At GMO Research, there are quite a few individuals from foreign countries who do not excel in Japanese, and may have trouble when reading messages written in this language. Likewise, there may be people whose mother tongue is Japanese, but do not quite master English.  For these cases, one may find online translators to be very helpful. It is only a copy-and-paste couple of actions away, and yet, when translating many individual messages, it can be rather time consuming. Furthermore, this action would have to be done by each person who wishes to know the translation for the messages. So then, what a better opportunity than to have these messages translated by a bot within Slack when requested?

The “slack-translate-bot” is what its name implies: a bot that translates, at request, text messages in a Slack channel, from Japanese, English, Chinese, or Spanish, into any other of these languages. 

The translation mechanism is triggered by putting an emoji reaction to the message wished to be translated. The emoji reaction is required to be the country flag corresponding to the language spoken in said country. Therefore, the supported emoji are:

  • 🇯🇵 for Japanese
  • 🇺🇸 for English
  • 🇪🇸 for Spanish and 
  • 🇨🇳 for Chinese (presumably, the Mandarin dialect).

A “thread” is opened under the message with the attached flag emoji, and there, the translation is written by the slack-translate-bot. It is possible to add different flag emoji to the same message, and the appropriate translations will be written as separate messages under the thread. In case several users react using the same flag emoji, the translation for the corresponding language will only be written once.

The slack-translate-bot was developed by Okazaki, one of our most talented senior engineers. In a talk given by Okazaki, it was revealed that the bot is simply a combination of two things: a lambda function and the AWS Translation API. 

An emoji reaction triggers a certain type of event in Slack, which makes a call on an API that executes the lambda function. This function simply looks at what flag it is, and if supported, makes a call to the AWS Translation API. This API returns the requested translation, and through the lambda function, it is put in the respective thread through a call to the Message Get / Post Slack API.

The slack-translate-bot is now widely used within our Slack workspace, mostly to translate back and forth between Japanese and English, but it is wonderful and very inclusive that support for Chinese and Spanish was also added. 

support_tool 

As part of our duties in the System Department, sometimes we may have to answer to inquiries by our coworkers involved in the operation of our products. Most of the time, they are able to solve most questions by themselves, but sometimes it may be needed to have a deeper look at the system logs and databases. 

Over time, and after years of tending to these inquiries, the Cloud Panel team in charge of these inquiries began to notice a trend in the type of questions that were asked, and it was concluded that part of these inquiries could be automated through the use of a bot, this time, called the support_tool. 

The support_tool is capable of executing two slash (/) commands: monitor_status and send_sales_report.

The slash command monitor_status, as it names implies, provides status information about a monitor, i.e. a person who answers surveys. Mainly, it is used to know if the monitor is valid, and if it is able to answer surveys. It may be that the monitor is somehow denied access from answering surveys, or unsubscribed from the service. 

The send_sales_report slash command is a lot different from the previous command, since it does not show any relevant information on the Slack conversation. Instead, it updates the sales information that is provided to our domestic sales team. This information update is necessarily performed at the request of our sales team, and it does not quite fit within our product ecosystem, which is why it was instead made into a slash command within Slack. 

The support_tool was created by our former colleague, Jimmy (王), and even though he’s no longer working with us, we think very fondly of him whenever we talk about this tool. Thanks to it, we have more time to perform other tasks that are not quite as repetitive as the above two. 

Today’s CRON check

Due to some changes in the way we manage the background processes, we no longer have to use this bot. Rather, we get a notification straight to one of our Slack channels whenever an error occurs. It was indeed very helpful in a previous time. 

In the huge platform offered by GMO Research, the Market Observer, various processes are running in the background on a daily basis, which provide some very important functions for it. At times, these processes, called informally “CRON batch”, may sometimes fail in their execution for a myriad of reasons. 

Whenever one of these CRON batches fail, we automatically receive an email describing where the task failed and at what time. And with this information, we can pinpoint the location of the error, and hopefully recover from it by e.g., by executing the batch again. It would be highly inefficient, time wise, for all people in the department to be looking at each and every email received, as it would include emails from other sources detailing system processes, for instance. Instead, one person from the department is designed daily to check any errors that could have occurred on a given day.

As we are not always conscious of when our turn to check the CRON is about to come, it is best if we are reminded about it. And thus, here is the role of the “Today’s CRON check” bot. Every day at 9:47 AM, the bot will output a message tagging the person in charge for the CRON on that day.

The Today’s CRON check bot was made by one of our PHP experts, Mukai .

cron-checker

The cron-checker bot is also related to the “CRON batches” that are executed in the background for various purposes within our Market Observer and related products.

Also, since we recently migrated the management of most of the cron badges to external software, this bot is not currently running either.

This bot provides a quantitative analysis on the errors occurring on a daily basis. Particularly, it checks if an NG word, e.g., “ERROR”, was present in any of the emails received by our error monitoring systems. The output itself is the number of emails containing NG words for the current day.

The cron-checker is very useful if one wants to have an overview of the overall execution status for the processes run in the previous 24 hours. It was created by the AI team lead, Fukuhara (福原), and it is still in use. Output for this bot is in Japanese only, and a translation is offered below:

This is the standard version. Good morning. I checked the email for you.

[Email body log link]

There may be an unknown NG word. Please confirm.

[Title log link]

The title log will contain the titles of all emails identified by this tool.

[Execution log link]

This is the execution log.

Wrapping up

In the above section, some of the most useful bot tools used within the Slack ecosystem were introduced. Thanks to them, many repetitive and time consuming tasks have been eliminated, and because of this convenience, productivity has without doubt increased in the System Department at GMO Research.

At the moment, I am developing in my spare time a small bot called postcard-bot which, although may not increase productivity, has the goal of fostering a positive environment within our company. I will not give any more details about it for now, but do look forward to my next blog post!

References:

Slack. What is Slack? Date of access: Nov. 6th, 2020.
https://slack.com/help/articles/115004071768-What-is-Slack-

開発ブログカテゴリの最新記事