I always forget to drink water, so I built a Twitter bot to remind me
Tags: learning, node, bots, documentation
Published: 2018-04-07 13:11:37

---
title: I always forget to drink water, so I built a Twitter bot to remind me
published: true
tags: learning,node,bots,documentation
canonical_url: https://medium.com/@endan/i-always-forget-to-drink-water-so-i-built-a-twitter-bot-to-remind-me-a12e28f31477
---

![](https://cdn-images-1.medium.com/max/1024/1*fSpHXKrUknfz7-qRi5L6_Q.png)

I have always been having trouble staying hydrated these days… especially at home. For hours, I get absorbed in a book and forget to drink water. This results to my skin and lips getting more dry. Recently, I’ve followed [lots of bots](https://twitter.com/jjjjcccjjf/lists/favourite-bots) to help me with my worldbuilding. Crossing these two ideas together, I thought _why not build a bot to remind me to drink water?_

I’ve always had this particular [post](https://dev.to/omarhashimoto/how-to-build-a-simple-twitter-bot-in-17-lines-ofcode-2aan) on my reading list on dev.to, and just this week I decided to finally read it. I also stumbled upon [this post](https://medium.com/@mattpopovich/how-to-build-and-deploy-a-simple-twitter-bot-super-fast-with-node-js-and-heroku-7b322dbb5dd3) as I was researching and ended up following it instead of the former.

### Tinkering the bot

Now here’s what I wanted to happen (initially). I simply want to make the bot remind me to drink water every 3 hours. So here’s my thought process on how I will achieve this.

1. Build a prototype locally. Make it tweet instead of retweet (referring to the first tutorial)
2. Make it tweet every 3 hours
3. Make it spout ̶r̶a̶n̶d̶o̶m̶ ̶n̶o̶n̶s̶e̶n̶s̶e̶ encouraging words to make me drink water
4. Create an algorithm of the sentence generator
5. Deployment

### Building a prototype

I went to [Twit’s documentation](https://github.com/ttezel/twit) and looked for how to tweet instead of retweet. The readme is kinda messy but at it’s understandable so it’s fine.

And bam! Here’s the _hello world_ tweet of my bot.

![](https://cdn-images-1.medium.com/max/1024/1*5G_hCeN4ee0zK3pHR9ZNKQ.png)<figcaption>Working example ✨</figcaption>

1. Apparently, you cannot post the same tweet in a row, so I appeneded the current timestamp there so it’s unique. (For testing purposes)
2. I used the [dotenv](https://www.npmjs.com/package/dotenv) dependency so I don’t share to the world my sensitive information and keys.

### Change of plans

Instead of actually following my list, I started at the deployment process first and then built my sentence generator locally. Here are some funny sentences!

![](https://cdn-images-1.medium.com/max/587/1*barJMouX64HY8RtUNkkaRQ.png)

![](https://cdn-images-1.medium.com/max/583/1*ZXzSmQtKuFAPo_leDdoopw.png)

The second tutorial takes advantage of Heroku’s add-on’s. I used a scheduler add-on to run the script every hour (instead of the initial plan 3 hours) and that’s about it.

![](https://cdn-images-1.medium.com/max/540/1*s6IXG8GsLSgq7jTJy22lhg.png)<figcaption>My initial screen shot</figcaption>

### That’s it!

This post is not a tutorial, just a documentation of my learning experience. If you want to be reminded every hour to drink water, then you can follow [@bot\_hydrated](https://twitter.com/bot_hydrated). 😅 It’s summer and it’s getting hotter and hotter! Gotta stay hydrated guys and gals! If you want to submit a pull request, here’s a link to the [repo](https://github.com/jjjjcccjjf/bot_hydrated). Feel free to fork it as well. This is just a fun project and I’m not sure if I’m going to take this one very seriously (for example, improve the bot in the future). I have several other bot ideas, though! So watch out for that. 😅

If you are reading this, thank you for reaching the end. 😎🙏 See y’all on the next ones!

EDIT: Fixed the wrong repo link