How you can use Slack Bots to improve team productivity

Get a head start on developing your own Slack Bot with the boilerplate on Hasura Hub

Slack is the instant messaging and collaboration app that has taken the world by storm. Over six million people use Slack daily at work, including employees at 43 of the 100 largest companies in the United States.

Slack, the team communication app taking the world by storm.

While there have been several attempts at building collaboration software before (we are looking at you Google Wave!), none of them have reached Slack’s level of popularity . The reasons attributed to this vary — from its design, which is atypical for enterprise software, to the marketing around Slack when it launched.

At Hasura, we have been using Slack for the last year (both internally and with our users — You can join our public slack channel here), and we can attest to its usefulness when it comes to facilitating team communication. For us, Slack’s killer feature has been its directory of integrations. We use the GitHub integration for keeping track of comments on GitHub issues, the Twitter integration for keeping track of social media activity and the Giphy integration to send each other cat gifs (Also other kinds of gifs. But mostly cat gifs).

In case the Slack’s list of apps aren’t enough, Slack also makes it easy for you to create your own integrations for your own particular use-case. The Slack Bot (not to be confused with the Slackbot, Slack’s own Slack Bot 😒), is one particular type of integration you can create.

What are Slack Bots?

To put it simply, a Slack Bot is a non-human user on a Slack channel/workspace triggered by a specific slash command (text preceded by a /). The bot will then take the command text and trigger some kind of event — a third party API call, a response, etc. Bots can thus be a way of interacting with third party apps directly from within Slack (which is where most of your team’s collaboration occurs).

Bots should be used to automate repetitive actions — for example, posting a bug to your bug tracking software, or setting up an event on your calendar, etc. Slack maintains a list of bots for the most common use-cases here.

However, every company will have its own set of workplace practices and processes, and therefore its own set of actions it wants to automate. For example, you might want a Slack Bot that turns on your Particle Photon enabled coffee machine. For companies that already use Slack, spending some time to build out your own Slack Bot is a worthwhile investment and can lead to immense productivity benefits. Or better coffee, which is the same thing.

Getting started with the boilerplate on Hasura Hub

To get started with developing your own Slack Bot, go to the Slack Bot boilerplate page on Hasura Hub, and follow the instructions in the Readme to clone and deploy.

Hub is where you will find community contributed boilerplates that you can extend and modify, to give you a head start on developing your application. These projects range from a react + nodejs boilerplate to a sample ecommerce schema to boilerplates for apps such as this one.

The bot featured in this boilerplate is written using Python, and allows users on a channel to post anonymous messages on the channel. The features of the bot are:

  1. Receiving a command from a Slack user triggered by them using the slash command /anonbot and storing the command in a database. This is an integration with the Slack Slash Command API, and the Hasura data APIs.
  2. Asking users for confirmation before the message is posted, featuring an integration with the Slack interactive messages API.
  3. Posting the message on the Slack Channel once it is confirmed, using the Slack Post Message API.
The Slack Bot featured in the boilerplate

Slack requires all bots to have API callbacks on HTTPS. Hasura auto generates certified SSL certificates for free (powered by Let’s Encrypt).

Extending the boilerplate

This Slack Bot features integrations with the basic Slack APIs. It serves as a good starting point for creating your first slash command, or for creating interactive messages. All of this will involve trivial modifications to the source code.

To help you further extend the boilerplate, the bot also saves the command text using the Hasura data APIs. You can add custom APIs and integrations that manipulate the data in some fashion (for example, running it through an Natural Language Processing API like wit.ai or Dialogflow) before posting a response, or trigger some action based on the command text (such as posting a feature request to your Trello board). With Hasura you can deploy these custom APIs and integrations with just a gitpush.

In case you do extend the project, do publish the result on Hasura hub, so everyone benefits from your work. For inspiration, you can check out this list here.

As part of the first Hasura #Pub2Hub challenge, we are also giving away Hasura swag boxes and 3 months of hosting credits to the best published projects!


Hasura is an open-source engine that gives you realtime GraphQL APIs on new or existing Postgres databases, with built-in support for stitching custom GraphQL APIs and triggering webhooks on database changes.


Hasura

Hasura

The Hasura GraphQL Engine gives you realtime, high performance GraphQL on any Postgres app. Now supports event triggers for use with serverless.

Read More