Use Twilio to create SMS notifications to keep your subscribers in the loop.
-
You will need to configure Twilio to send requests to your application when SMS are received.
You will need to provision at least one Twilio number with SMS capabilities so the application's users can join the loop. You can buy a number right here. Once you have a number you need to configure your number to work with your application. Open the number management page and open a number's configuration by clicking on it.
Remember that the number where you change the SMS webhook must be the same one you set on the
TwilioPhoneNumber
setting.Keep in mind that our endpoint is:
http://<your-url>/message
-
Clone this repository and
cd
into it.git clone [email protected]:polymerwitch/pa_messenger.git
-
Create a new virtual environment.
python3 -m venv venv source venv/bin/activate
-
Install the requirements using pip.
pip install -r requirements.txt
-
Edit the config file (pa_messenger.cfg) inside the root of the project, and be sure to replace the place holders and connection string with real information.
SECRET_KEY = 'your_authy_secret_key'
TWILIO_ACCOUNT_SID = '[your_twilio_account_sid]' TWILIO_AUTH_TOKEN = '[your_twilio_auth_token]' TWILIO_NUMBER = '[your_twilio_phone_number]'
SQLALCHEMY_DATABASE_URI = 'sqlite://' ```
-
Run the migrations.
python manage.py db upgrade
-
Start the development server.
python manage.py runserver
That's it!
You can run the tests locally through coverage:
-
Run the tests.
$ coverage run test.py
You can then view the results with coverage report
or build an HTML report with coverage html
.
For smaller loops you can run this on a free dyno from heroku
-
Get the Heroku cli Heroku-Cli
-
cd into the cloned project directory
$ cd pa_messenger
-
Login to Heroku
$ heroku login
-
Create the heroku app
$ heroku create my_text_app
-
Ensure pa_messenger.cfg is configured as outlined above and commit the changes. The database url can be gotten with:
$ heroku config
-
Set heroku to be production
$ heroku config:set ENV=production
-
Set heroku to read the config file
$ heroku config:set PA_MESSENGER_CONFIG=../pa_messenger.cfg
-
Push the app to Heroku
$ git push heroku master
-
Scale the dyno
$ heroku ps:scale web=1
-
Setup the DB
$ heroku run python manage.py db upgrade $ heroku run python manage.py db migrate
-
You should be set!
- No warranty expressed or implied. Software is as is. Diggity.
- MIT License
- Lovingly crafted by Twilio Developer Education.