How to Set Alarms using Google Calendar Events and Twilio Voice
November 17, 2018 • 4 min read
Motivation
Have you ever been in a situation where you have to wake someone up by calling them? Specifically, have you ever been in a relationship where you have to wake up your significant other by giving them a phone call? If they don't wake up with one phone call, you'd have to keep trying.
Personally, I’ve always disliked the idea of doing mundane tasks, which is why most of the projects on my GitHub are to automate little things with scripts.
Before I delve into building a completely new app, I googled to check if someone else has created a similar app
1 where you can automate phone calls. I couldn’t find any exact app that could solve my problem.That’s why I created wakie wakie. Check out the code ⚡️
Solution
This application can be broken down into 2 components:
- Twilio Voice — A service that makes phone calls.
- Zapier — A trigger that prompts a service to make phone call at a certain time.
Twilio Voice Setup
A simple query of phone calls api
on Google led me to How to Make and Receive Phone Calls with Python, Bottle and Twilio Voice - Twilio
This tutorial fits perfectly to my use case, however, it is not ideal for me to start a localhost using ngrok and run a Python script every single time.
Instead, I’ve decided to deploy my app on Heroku and make it easier for a Callback URL trigger using GET request.
Heroku Deployment
Go ahead and clone/fork my wakie-wakie repo
$ cd wakie-wakie
$ heroku create
$ git push heroku master
$ heroku open
# you should see "wakie wakie is up and running!"
Once it’s up and running, you have to get a dummy phone number from Twilio Voice and config vars on the Heroku app.
Hover left section for All Products and Services
→ Look for Phone Numbers
→ select a dummy phone number of your choice
Now you have to config the vars (ACCOUNT_SID, AUTH_TOKEN, APP_LOCATION) for your Heroku app. You could either do it on Heroku CLI or the web interface, as shown below:
After selecting a phone number, you have to config the base url of your herokuapp.com, as shown below:
You also have to config app.py and update the <outbound_phone_number> with your dummy phone number. This acts as a POST request in which Twilio Voice will dial with your outbounding dummy phone number.
Up until this point, you can go ahead and dial your own number using https://wakie-wakie.herokuapp.com/call/<YOUR_OWN_NUMBER>
I know what you're thinking, it is time to prank your friend 😉. Unfortunately, you are only allowed to use your dummy outbounding phone number to dial a Twilio verified phone number.
Trigger with Zapier
In this step, I've utilized Google Calendar event and Zapier to automate this process. The logic is very simple 🤗
If I set a Google Calendar Event that begins at 7am, Zapier will pick up the keyword from Google Calendar and trigger Twilio Voice.
Let's make a Zap!
Trigger: Google Calendar
- Event Start
- Connect your Google Calendar
- Search Term:
wakie wakie
Action: Webhooks
- GET
- URL:
https://wakie-wakie.herokuapp.com/call/<YOUR_OWN_NUMBER>
Voila! 🎉
Now you can trigger phone calls by setting Google Calendar events. I can't wait for you to try it out and let me know how it goes.
Credits to Matt Mireles Goodbye, Alarm Clock. How I Hacked Google Calendar to Call My Phone in the Mornings.