TwilioDevEd / appointment-reminders-flask

Use Twilio to send SMS reminders to your customers about upcoming appointments
https://www.twilio.com/docs/tutorials/walkthrough/appointment-reminders/python/flask
MIT License
75 stars 34 forks source link
twilio-sms

Twilio

Twilio's Appointment Reminders with Flask

Coverage Status

Use Twilio to send SMS reminders to your customers about upcoming appointments. Learn how appointment reminders help other companies in these Twilio customer stories.

Read the full tutorial here!

Quickstart

Local development

This project is built using the Flask web framework. It runs on Python 2.7+ and Python 3.4+.

To run the app locally, first clone this repository and cd into its directory. Then:

  1. Create and activate a new python3 virtual environment.

    python3 -m venv venv
    source venv/bin/activate
  2. Install the requirements using pip.

    pip install -r requirements.txt
  3. Copy the .env.example file to .env and add the following values. Be sure to replace the placeholders 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]'
  4. Create Flask application variables

    export FLASK_APP=reminders 
    export FLASK_ENV=development
  5. Run the migrations.

    flask db upgrade
  6. Start a redis server to be our Celery broker. If on a Mac, we recommend installing redis through homebrew If you already have docker installed in your system an easy way of get redis running is:

    docker run -d -p 6379:6379 redis:latest
  7. Start the development server:

    flask run

You can now access the application at http://localhost:5000. To send any reminders, however, you must also start a separate Celery worker process.

  1. Start a new terminal session, cd into the repository, and active your appointment-reminders virtualenv

  2. Activate Flask development environment

    export FLASK_ENV=development
  3. Start the Celery worker:

    celery -A tasks.celery worker -l info

Celery will now send SMS reminders for any new appointments you create through the web app.

Run the tests

You can run the tests locally. Follow the instructions in the Local Development section above, and then run:

python runtests.py

You can then view the results with coverage report or build an HTML report with coverage html.

Meta