Minimum Viable Slackbot: with GitHub Python Code

This image is freely available under the Creative Commons Attribution-ShareAlike license.

Clone this repo, install the dependencies as listed in the readme, and you’re good to go.

Copy it with:

git clone https://github.com/julianeon/slackbot.git

This is a minimum viable standup bot. It is intentionally basic, for ease of understanding.

If your needs are simple, you may be able to customize a few questions and use as is. For days when an in-person standup is either impractical or unnecessary, a standup bot can fill the gap. Think of this as a roll-your-own tatsu.io.

Constants are given at the top, for ease of access. Paths will need to be changed, depending on your setup.

A YAML file is included, which the bot consults. YAML is a concise format with examples given to clarify its use. You’ll want to look up your user and channel ID’s in Slack and substitute them in for the dummy values.

You can find this information, using Slack’s API tester page, using their methods; “users.list” and “channels.list” are the chief ones.

The bot can be found in bot.py.

Question Array is the list of questions to ask.

Title Array amounts to “questions, summarized for printout.”

For example, if the bot asked you your age and printed it out, the source in the Python code might include this:

QUESTION_ARRAY=[“How old are you? Please give your answer as a number, in years.”]TITLE_ARRAY=[“Age”:]

As this implies, Question Array and Title Array can be the same array, if that’s how you want to do it.

The asker method iterates through the questions and asks them sequentially of each user, one after another. That is why there’s a mechanism to move on if a user doesn’t answer (otherwise, it would hang on an absent user forever). If the user takes too long to answer, it prompts him for an answer. If he still doesn’t answer, it skips him. If the user types ‘ignore’, it also passes. Otherwise, it asks the questions it has to ask, then moves on to the next user.

The fetch method fetches the answers; it starts once all the users have been asked by the asker method. It gets the answer object from Slack, the response JSON. That object gives the conversation in reverse order, with the most recent statements coming first. It reverses the list of printed questions (qa_list = qa_list[::-1]), finds the user’s answers and matches them to the summarized question, and returns that array.

Finally, the bot takes all those answers, aggregates them, and prints them to the designated room.

There it is: your MVP standup bot. Feel free to clone, adapt, remix and reuse, under the MIT license. Share and make your own pull requests, if you’d like for me to include your clever improvements.

Finally, thanks for reading!

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store