This is a toy project to learn the basics of Twilio (and also Flask, redis, redis queue). It functions as a timer/reminder that is set up by the user by SMS and the reminder with the message is communicated to the user after the given time via a phone call and an SMS.
- Use the following to install pip and virtualenv (https://www.twilio.com/docs/quickstart/python/devenvironment#installing-python)
- Clone this project and cd into it
- Install dependencies
pip install -r requirements.txt
- Install redis
- Install ngrok to be able to make a public tunnel to your localhost
Start by setting up background services
- Redis server
redis-server &
- RQ server and scheduler
rqworker &; rqscheduler -i 10 &
- Edit run.py to have your Twilio account details and a Twilio number
- Run run.py
python run.py
- Run ngrok in another terminal
./ngrok http 5000
to make a public tunnel to your localhost - Copy and paste the URL of your server into the "SMS" URL of a number on the Numbers page of your Twilio Account.
All commands must be sent as an SMS to the Twilio phone number. Currently 2 commands are supported "timer" and "reset".
To set a timer send the following:
timer <time value> <time unit min/hour> "message"
e.g "timer 5 min "Call mom!""
or "timer 8 hour "Stop being lazy and wake the hell up!""
You should receive a confirmation SMS instantly and after the given time you will receive a phone call from the Twilio number hearing your message, SMS is also sent.
To cancel all timers for the sender:
reset
You should receive an SMS confirmation with how many timers were cancelled for you.
- List current timers
- Move cancelling all messages into a RQ job to make it more scalable instead of doing it in the REST service