Motivator Bot [ Slack bot ]

Ashish Prasad
6 min readJul 11, 2021

If you forget things, count me in. If you don’t, still don’t bother to remember everything. 🤭

~ Motivator Bot

Did you ever miss a calendar event because you forgot to check it? Or did you miss a Github issue which could’ve been worked up on earlier only if you checked it ? Ever forgot doing something because you didn’t have reminder in place ? Or ever felt the need to have someone who wishes you happy things without any intention or greed ? 🥺

Ideation 🤔

Well, you are not alone, we are on the same page, so when I came to know about @Crio.do Crio #IBD Remote Working Tools edition, I thought why not to give my thoughts a go. I thought a chat bot could do many of the things that we can’t even imagine. Have used several telgram or discord bots, such as stock buy/sell signal bots, to mention the least. Why not make my own one for Crio #IBelieveinDoing edition? 👩🏻‍💻

I thought to make a bot which helps me/people like me in their day to day office work. I wanted to make it in a way that can be scaled up, and updates to it can be rolled out in an efficient way. Bot making has a lot of scope for learning and improvement, and something which takes time to make it robust. A bot that is usable and isn’t an annoyance. And a bot who is a good friend. 🤭

So which platform to write bot for ? There are lot of options, discord, telegram, flock and what not. But I thought, since I am well known to Slack UI and workspace since I am doing job in a firm that entirely uses it, and well Crio uses it as well, felt it would be a good try to explore the API documentation of slack. 👀

I wanted the bot to tackle the pain points faced by me :

a. Monday motivations and some good vibes daily. 😛
b. I shouldn’t forget simple things, and would like to have something that reminds me of what to do and when to do. ⏱
c. Don’t want to miss Google calendar events. I missed my first retrospective once and that’s something I dont wanna miss ever.🗓
d. Have something in place that alerts me when I am tagged or an issue is created or someone creates branch of a repository. ⚠️
e. A shortcut to locate the repositories, from slack itself because its else too much of redirection. 🚴🏻‍♀️

Planning 🧐

So I started traversing the Slack Web API, and Events API, could split the tasks into milestones of learning ( the Crio way aka Learn by Doing), such that

  1. Learning how to create slack bot from the API
  2. The authentication flow to use it in Javascript code
  3. Identifying the permissions needed to perform specific actions (I dont wanna give unnecessary permissions to the bot which I can’t risk to be accountable for if someone else uses it)
  4. Third Party Integrations (read tough cookie 🍪 ) research
  5. API research and debugging raw calls in postman
  6. Testing the code and modularizing, optimizing, identifying dead code and code smells. ( read sonarQube or Code Inspector docs, avoid tech debts(for long term) )

Specifics

So I created atleast 3 to 4 bots to understand what each different permission set causes the bot to behave. Looked a lot through API documents to understand use case of each permission set.

The tech stack focused on the following :
1. To send good greeting messages and reponses :
Identified the free APIs
https://api.adviceslip.com/advice
https://www.affirmations.dev
https://type.fit/api/quotes

2. Authentication Flow and Bot types :
Studied Auths, Legacy bot, New OAuth Bot, Differences between both, which one would be best to use. (I got stuck here for good amount of time 😅)

3. Identifying the permissions and functionalities I would need :
Events API, Event Subscription, Webhooks, Slash Commands, Socket mode : when to use and when not to, App manifest

4. Third Party Integration (read tough cookie ? )
For this I preferred using a middleware for the time being, Pipedream API came as a boon, could integrate a lot of things in it with the able to code at runtime inside it. Had some gotchas which are expected when you use such tools but it is a great middleware to integrate codes with third party. (Learn oAuth flows before diving in for middlewares for third party applications if you have plenty of time)

Studied Google Calendar API and Github API to see what all are the possibilities, to be honest, its endless but tried to implement the alerts that are most important and feasible to implement for time being.

Following are the Integration workflows that I created to integrate and run events/webhooks from Github to Slack, Webhook to Github and Calendar to Slack.

5. Understanding scheduling and using it in the system.
Gotchas and caveats around it.

6. Studying the documentation of libraries such as

  • Slack Events API
  • Slack Web API
  • friendly cron
  • node cron
  • axios
  • ngrok

So whats the working model :

A simple bot which pushes you forward to do more with the help of alerts, reminders, schedulers, and Github, Google Calendar Integrations.

  • How many times do we miss or get late on checking Github issues, mentions, or branch alerts. No more now, using Pipedream API to integrate Github, now one can directly get notified when they are mentioned, or a branch is created, or issue is raised for a repo.
  • Have you dozed off with naptime while a calendar event was scheduled for next one hour and so you missed it ? Say no further, you can now get alerts if there’s a meeting in an hour with help of Pipedream integration and some JS snippets.
  • Want to quick search your favorite github repo stats, or get issue counts, no need to open chrome. Just /searchrepo it.
  • In order to stay on track and to not miss out anything, one can set reminds for himself or for channel with precision of minutes or hours or days. Just remindme or remindus it
  • Want to set scheduled messages with a friendly precision, you got it. Just schedule it
  • Often during work all we feel is a need to find some positivity to deal with anxiety, stress or fear or even imposter syndrome. Sometimes words are the best friend we need. This bot posts a randomized good morning alert, advice at noon, and quotes in evening.

The screenshot highlights one of the supported keyword, help, which returns the possible functions that it can do. These 6 functionalities cover pretty much all what the bot is capable to do as of now.

Thats it, folks. Will upload more such blogs around new updates made to the bot. Thanks for reading. Have a good day. And clap please. 👏 🤭

#CrioIBDRemoteWorkingTools #IBD Remote Working Tools Crio #IBelieveinDoing #CrioIBD #IBelieveinDoing #LearnbyDoing #Criodo #IAmaBelieverofDoing

--

--