A simple sms bot for mediating music recs between strangers
This is a flask app that handles text message exchanges with strangers. It uses Twilio to send/receive SMS.
In a nutshell, the app:
- texts a prompt (currently the topic is music recs, but this can be adapted to fit other topics)
- stores responses
- texts randomly selected responses from strangers
- texts notifications when responses have been seen
- allows admins to moderate responses
UPDATE: the music swap bot used to live at 1-415-851-7927, but unfortunately it needs to be shut down due to high usage (i.e. high costs). If you're interested in reviving it, reach out: cathyd125 at gmail
1. Make sure you have OS level dependencies
- Python 3
- MySQL
2. Clone this repo
git clone https://github.com/buzzfeed-openlab/sms-music-swap.git
cd sms-music-swap
3. Install required python libraries
Optional but recommended: make a virtual environment using virtualenv and virtualenvwrapper.
Notes:
- Instructions for setting up virtualenv here.
mkvirtualenv sms
will automatically activate thesms
environment; to activate it in the future, just useworkon sms
- if the virtualenv you make isn't python 3 (check w/
python --version
), usemkvirtualenv sms -p /path/to/your/python3
(find your python3 path withwhich python3
)
mkvirtualenv sms
Install requirements:
pip install -r requirements.txt
4. create a MySQL database
mysql -u root
& then
create database sms;
If you're working locally, you're good to go. But if you're going to host this on a shared server you probably want to create a new user for this database instead of using root
.
5. Configure the app
There are two ways to do this: (a) making a config file or (b) setting environment variables.
You will need a twilio account & number to configure the app. (INSTRUCTIONS TO COME)
Option A
Copy the example secret config file
cp sms_swap/config_vars_secret.py.example sms_swap/config_vars_secret.py
Then, edit sms_swap/config_vars_secret.py
.
Option B
see sms_swap/config_vars_secret.py.example
for the names of environment variables to set & descriptions of what the values should look like.
6. Run the app locally
python application.py
7. Initialize the database
Visit the /initialize
route (e.g. localhost:5000/intialize
) & enter admin credentials (ADMIN_USER
& ADMIN_PASS
). This will create the table for storing responses.