Never Forget A Friend's Birthday with Python, Flask and Twilio
This app lets you:
- import your Facebook birthday calendar,
- send SMS notification messages of upcoming birthdays,
- send text messages and simple ecards via SMS.
-
Clone this repo:
$ git clone https://github.com/pybites/bday-app
-
Make a virtual env and install dependencies:
$ cd bday-app $ python3 -m venv venv $ source venv/bin/activate $ pip install -r requirements.txt
-
Create a Twilio account, get a phone number and API key (sid) and token.
-
Copy the settings template in place:
$ cp env-example.conf env.conf
-
Update it with the correct settings:
- flask - secret = set this to a random, hard to guess string (see Flask docs)
- twilio_api - sid + token = obtained in step 3
- phones - twilio = obtained in step 3
- phones - admin = your (verified) mobile phone number, where you want to receive notification messages
- login - user + password = define your login credentials for the Flask app
- server - url = unchanged if running locally, update to base URL if deployed elsewhere (so far I only tested it on my localhost)
NOTE: make sure you use E.164 number formatting for phone numbers (e.g. +34666555444, +442071838750). See Twilio's support article: Formatting International Phone Numbers.
-
Import your FB calendar into local SQLite database with birthdays
This app has two parts:
-
The notifier which checks once a day for birthdays. If there are one or more birthdays that day it sends out an SMS to your configured admin phone. You need to run this as a background job so use
nohup
:$ nohup ./notify.py &
-
The front-end is a Flask app which you can invoke with:
$ python app.py
Note that for both scripts you need to have your virtualenv enabled.