This project allows you to schedule and receive reminders to take your medication via SMS. The app was developed for Twilio App Bootcamp and is written in Python using Flask and RQ.
We assume that before you begin, you will have Python and pip installed on your system and available at the command line.
Before you can run this project, you will need to set three system environment variables at .env. These are:
TWILIO_ACCOUNT_SID
: Get it from your Twilio Console.TWILIO_AUTH_TOKEN
: Same as above.TWILIO_PHONE_NUMBER
: A Twilio number that you own, that can be used for making calls and sending messages. You can find a list of phone numbers you control (and buy another one, if necessary) in the console.
The next step is to make a .env (note the leading dot) file where we will store the environmental variables that will serve as configuration for our project. You will need to replace all the characters after the =
with values from your Twilio account:
TWILIO_ACCOUNT_SID=SID_HERE
TWILIO_AUTH_TOKEN=TOKEN_HERE
TWILIO_PHONE_NUMBER=+16518675309
An example is provided at .env.config.example.
You will need to have an instance of Redis installed and running. It is also recommended to have Ngrok installed to expose the Flask web app for testing.
Type below to install Redis and Ngrok on macOS:
brew update
brew install redis
brew cask install ngrok
-
Clone this repository. Navigate to the folder with the source code on your machine in a terminal window.
-
From there we recommend creating a virtualenv and activating it to avoid installing dependencies globally on your computer.
virtualenv -p med-reminder env
source env/bin/activate
-
Install dependencies:
pip install -r requirements.txt
-
Start Redis:
redis-server /usr/local/etc/redis.conf
-
Spin up RQ worker to take on jobs:
rq worker --with-scheduler
-
Run the web app:
python app.py
-
Open the app in your browser.
-
Expose your web app with ngrok in order to receive Twilio SMS requests.
ngrok http 8080
-
Copy the ngrok public url shown in your terminal. It should look similar to the example below.
Session Status online Version 2.3.35 Web Interface http://127.0.0.1:4040 Forwarding http://92832de0.ngrok.io -> localhost:8080 Forwarding https://92832de0.ngrok.io -> localhost:8080 Connnections ttl opn rt1 rt5 p50 p90 0 0 0.00 0.00 0.00 0.00
-
Go to the Twilio Console to configure your Twilio phone number to make a request to your public url when a message comes in.
-
SMS to the Twilio phone number you have specified and watch the magic happen!
Commands Available:
1. List
2. Remind <medicine> <dosage per day (1-5)> <how many days>. E.g. Remind Paracetamol 2 3
3. Delete <medicine>
-
Redis Commander, an open-source web management tool to manage Redis
-
RQ dashboard, a lightweight webbased monitor frontend for RQ