Reminders on Whatsapp

We talk about setting up reminders on Whatsapp so we don't forget the important stuff.

Reminders on Whatsapp

We talk about setting up reminders on Whatsapp so we don't forget the important stuff.

Everyone needs reminders. Some of us even use dedicated apps for them. I personally use Todoist to manage most of my recurring tasks but something I do use a separate app for are reminders to drink water. So I thought, what if we added them to our Whatsapp bot as well?

Let's talk about how we are going to go about implementing this. There are several parts to it, we need:

  • For our server to know when to send out these reminders. We can do this via a cron job. Using a cron service, we can send a request to our server every X hours.
  • To set up our server to receive these requests and parse them. The reason we're parsing these requests is because in the future, we want to be able to send different types of reminders.
  • Once we parse the request, we want to tell our server to send us the reminder on Whatsapp.

Cron Job

To set up our cron jobs, we're going to use the EasyCron service. They have a free plan that should be more than enough for some basic reminders. I personally would like to receive a reminder every 2 hours between 8am to 11pm. This is what the cron expression for that looks like 0 08-23/2 * * *. As for the request itself, I am going to use the /reminder route and make it a POST request. We can also send the message within the request itself, that way, we don't have to hard code anything on the server.

Receiving the request and sending the message

To receive the request, we simply need to create a new route that accepts post requests on /reminder and parse it to get the message.'/reminder', async (req, res) => {
  const { message } = req.body;

And to send the reminder to ourselves on Whatsapp, we simply need to use our existing Twilio setup to create a message.

try {
  await client.messages.create({
  	// This is the number you get when you sign up on Twilio.
    from: TWILIO_NUMBER,
    body: message,
    // The number you want to send the message to.
    to: MY_NUMBER
} catch (error) {
  console.log('err', error);
  // We get the status and message fields from the error sent by Twilio.

Once we set all of this up, our reminders should start flowing in. But, there's one small caveat. Twilio has this thing called 24 hour sessions where we can only send these notifications if the user has sent our bot a message in the last 24 hours. I personally use this bot everyday so this isn't an issue I will run into but just in case you don't, you can set up a simple command and have the bot respond to it. I went for a simple thanks command because I thought it'd be nice to thank the bot given it was constantly reminding us to stay hydrated. Here's what it looks like!


Using this as a framework, we can go ahead and create any type of reminder we want. We can even go as far as setting it up in a way that we can add reminders through Whatsapp, maybe I'll explore that in a future post. Let me know if that is something that interests you!

And as usual, you can find the updated code on Glitch and feel free to message me on Twitter in case of any questions!


Faraz Patankar

Probably obsessing over fantasy football, figuring out what to eat for my next meal or working on my next great (soon to be abandoned) side project but hello to you too! 🤗

More posts from this author