Spicing up our work atmosphere with Slack

By Thibaud Robelain & Flavien Raynaud, on 09.18.2015

Communication within a team made up of scores of people can be hard, which is why using a proper messaging tool became an urgent need at Applidium. We decided to give Slack a try and it didn’t take us long to adopt it fully, thanks to the great features it comes packaged with.

On top of the usual direct messages, Slack lets us create public channels everyone can join, as well as private channels with restricted access. This eliminates the need for internal emails and allows us to move forward faster, as it decreases the usual email reply latency.

Slack integrations

The beauty of slack resides in the fact that a lot of services that you wouldn’t normally find in your usual real-time messaging tool can be seamlessly integrated with it. For instance, at Applidium, we use integrations for tools such as IFTTT, Jenkins, and Google Drive, which are all facilitating communications on our projects. In addition to those pre-configured services, Slack offers integration capabilities that enable developers to communicate with it, either to get data into slack or out of slack. These integrations are named “Incoming WebHooks” and “Outgoing WebHooks”.

Incoming WebHooks, as their name suggests, are a way to get data into slack. We’ll describe how we used them to create a bot whose job is to pair people so that they grab lunch together the next day.
Outgoing WebHooks are a way to get data out of slack, but this type of hooks isn’t limited to only that. Slack may receive answers from the servers to which it sends data, meaning that they can process the data and reply afterwards. Slack then displays the answers in the appropriate channel.

Cyril - an Incoming Webhook example

Incoming webhooks allow external systems to post messages into channels. The way they work is pretty straightforward: admin users can create an incoming webhook to the channel of their choice and they will be given an URL, the system has to send an HTTP POST request to this URL with a JSON payload and the payload will be dispatched to the corresponding channel.

Every Friday at noon, Applidium employees are grouped into pairs, with each pair grabbing lunch together, in order to get to know each other better. Because making dozens of pairs by hand every week is a tedious task, we developed a bot, Cyril (in honor of the well-known french chef Cyril Lignac) and plugged it to an incoming webhook.

Every Thursday, Cyril wakes up from sleep and generates random pairs using users currently connected on our #general channel, then posts these pairs.

Here is an example payload we might post to Slack:

{
  "text": "Et voici votre partenaire gourmand et
           croquant pour le déjeuner : ……"
}

Once dispatched, the payload looks like this:

Zizou - an Outgoing Webhook example

At Applidium, we usually partake in some video game activity during the lunch break. We take FIFA very seriously, and, for that matter, we decided to write our own “FIFA bot” for Slack. This is a typical example of something you can do to leverage the power of Outgoing WebHooks. We created a dedicated channel named #fifa, for which we’ve configured an outgoing webhook using the trigger word “’fifa”. Every message beginning by “fifa” sent in this channel is then sent as a POST request on the endpoint specified in the configuration of the hook. This POST message typically looks like the following (some parameters were omitted for clarity) :

{
  "token": "YOUR_SLACK_TOKEN",
  "text": "fifa stats @player",
  "trigger_word": "fifa"
}

We wanted our bot to take care of the rankings for us, using both the players results in the match and the teams they played with. With that in mind, we designed a set of commands to help players save their matches in the easiest way. Here’s a list of the current commands:

  fifa addteam TEAM atk mid def // adds a team
  fifa teams // lists all the teams registered
  fifa stats @slack_username
  fifa match @slack_user team score @slack_usr2 team score
  fifa 2v2 @user @user team score @user @user team score
  fifa undo // deletes the last match registered
  fifa ribery // replies with a random Ribery quote
  fifa challenge @slack_usr time(optional)
  fifa ranking // replies with the full league table
  fifa r // mobile-friendly version of the table
  fifa ranking2 // 2v2 full league table
  fifa r2 // 2v2 mobile-friendly table

Internally, the bot uses the Elo rating system to update the player rankings whenever a match is recorded. We’ve incorporated the overall rating of a team into this calculus, which means winning with a lower division team against the likes of Real Madrid, Bayern, and many others, gives you more points than the other way around.

As of September 10th, the bot has now registered more than two hundred games, about 3 and a half months after it’s been integrated into our Slack.

Source code

If what you’ve read has made you interested in getting either Cyril or Zizou for your Slack, they’re available on github.

Don’t forget to watch some of our best goals on Twitch @Fifapplidium !