Back to Parent

Outcome


Summary

BreatheIO is a simple Slack bot that prompts you to take a deep breath in and out over a certain time interval, along with a calming gif. BreatheIO helps incorporate good mental health habits into the workplace in a playful way. You can summon BreatheIO with the command “/breathe” to launch into a deep breath, on-demand. Push notifications tell you how long to inhale and exhale, and you’re rewarded for your focus with a calming gif. Users can edit the length of breaths, or simply pick a “chill gif” randomly, and breathe at their own pace without a counter.

Features: Desired and Implemented

Screen shot 2016 12 14 at 6.27.29 pm
Show Advanced Options

Workflow

The workflow begins with an introduction to breatheIO bot, encouraging the user to start breathing. If they click “Start breathing” they will begin the 10 second default breath.

If they click “Edit exercise” they will be asked a follow up question asking how long of a breath they’d like to take. After entering a number, the breathing exercise will begin with the number they selected.

At the end of a breathing exercise, users receive a gif and encouraging message, along with a reminder to use “help” to see all commands.

When the user enters “help,” they see all possible commands, including the “chill gif” Easter egg. When users type “chill gif,” they see a random gif from the chill gif database.

Breatheiowork
Show Advanced Options

Personality

If breatheIO bot were a person, they would be a Hawaiian surfer and monk, combining the laid-back humor of a beach bum with the thoughtful serenity of a theologian. His personality is expressed whenever you launch into a new breath with the “new breath” trigger word by saying “Need a breather? That's what I'm here for” and showing a levitating sock monkey. He is helpful without being pushy. When you’ve completed a breath, he says “Whew, that felt good. Type '/breathe' whenever you want to take another breather with me!” — encouraging, informational, and colloquial.

Technical Implementation

BreatheIO is a Slack bot built in Ruby and Sinatra. It leverages features in the Slack API such as interactive button messages and media attachments, as well as slash commands and incoming and outgoing webhooks. Gifs urls are stored in a database (Sqlite in development and Postgres in production), and pulled dynamically for the “chill gif” trigger word. The database is managed through the Active Record gem, which I used to access the models for the gifs, events, and slack team information. I also used the json gem to make blocks of json interpretable to Slack, which sends and receives JSON messages.


Media and Documentation

Screen shot 2016 12 14 at 6.30.15 pm
Show Advanced Options
Inslack2
Show Advanced Options
Screen shot 2016 12 14 at 6.35.50 pm
Show Advanced Options
Screen shot 2016 12 14 at 6.40.09 pm
Show Advanced Options
Chillgif3
Show Advanced Options

Future Work

Through the process of making breatheIO bot, I became familiar with Slack webhooks and the Slack API. I learned how authorization works in apps, using an oAuth endpoint to authorize users securely. While I found it straightforward to use template code to generate text and/or JSON attachment responses based on trigger words, I struggled with interpreting user responses within a chat flow and using those responses like variables to trigger methods, like the breath counter.

For editing the breath length, in this iteration, I used regular expressions to identify numbers in responses at any point in the chat and then use that number as a parameter for a counter method. However, in the future I would like to refactor the code to only play an edited breath counter at the proper point in the conversation flow, and also allow multiple responses.

I also struggled with some of Slack's default error messages, which showed as ephemeral messages even when there was no error — such as a timeout message that displays because the counter response deliberately lasts over 3 seconds (Slack's timeout limit) and an error upon clicking interactive buttons that displayed along with the correct responses. In general, I found Slack apps weren't intuitive to test and debug, since I couldn't (as far as I know) rely on console logging and viewing the source as debugging methods. I would look more into using cURL and other ways of testing and debugging my app.

Finally, I ran out of time to implement the scheduling feature (not shown) with the Heroku scheduler. I couldn't find any sample code for adding a rake task to the Heroku scheduler based on a variable in the user's response (for example "every day" or "every hour"). I hope to research this more and implement scheduling in my next iteration. I also hope to explore other features, such as allowing users to customize number of breaths, as well as the gif they would like to display.

Drop files here or click to select

You can upload files of up to 20MB using this form.