Skip to content

SnakeJazz/call-forwarding-flask

 
 

Repository files navigation

Twilio

Advanced Call Forwarding with Python, Flask, and Twilio

Build status

Learn how to use Twilio to forward a series of phone calls to your state senators.

Local Development

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

To run the app locally, follow these steps:

  1. Clone this repository and cd into it.

  2. Create a new virtual environment with virtualenv:

    virtualenv venv \
    source venv/bin/activate

    This application is compatible with Python versions 2.7 and 3.5, so feel free to use whichever installation you prefer in your environment.

  3. Install the requirements:

    pip install -r requirements.txt
  4. Run the migrations:

    python manage.py db upgrade
    
  5. Seed the database with data:

    python manage.py dbseed
    

    This will load senators.json and US zip codes into your SQLite database. Please note: our senators dataset is likely outdated, and we've mapped senators to placeholder phone numbers that are set up with Twilio to read a message and hang up.

  6. Expose your application to the internet using ngrok. In a separate terminal session, start ngrok with:

    ngrok http 5000
    

    Once you have started ngrok, update your TwiML application's voice URL setting to use your ngrok hostname. It will look something like this in your Twilio console:

    https://d06f533b.ngrok.io/callcongress/welcome

  7. Start your development server:

    $ python manage.py runserver
    

    Once ngrok is running, open up your browser and go to your ngrok URL.

Run the Tests

Run the tests locally with coverage:

coverage run manage.py test

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

Note: If coverage seems to run way too many files, you can omit directories by adjusting your coverage command to something like coverage run --omit=venv/* manage.py test. See the coverage docs for more information.

Meta

  • No warranty expressed or implied. Software is as is. Diggity.
  • MIT License
  • Lovingly crafted by Twilio Developer Education.

About

A sample implementation of advanced call forwarding using Twilio and Flask.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 88.4%
  • HTML 5.3%
  • CSS 4.4%
  • Mako 1.9%