Skip to content

A sample app for automated phone surveys with Twilio, TwiML, Python and Django

Notifications You must be signed in to change notification settings

chrisrobbo5/automated-survey-django

 
 

Repository files navigation

Automated surveys (Django)

Build Status

Use Twilio to conduct automated phone surveys.

Quickstart

Heroku

This project is preconfigured to run on Heroku. Deploy it now:

Deploy

To view your app, click the ... menu in the top right corner and select Open app.

Local development

This project is built using the Django 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 a new virtual environment:
    • If using vanilla virtualenv, run virtualenv venv and then source venv/bin/activate
    • If using virtualenvwrapper, run mkvirtualenv automated-surveys
  2. Install the requirements with pip install -r requirements.txt
  3. Start a local PostgreSQL database and create a database called surveys
    • If on a Mac, I recommend Postgres.app. After install, run createdb surveys;
    • If Postgres is already installed locally, you can just run createdb surveys from a terminal
  4. Run the migrations with python manage.py migrate
  5. Optionally create a superuser so you can access the Django admin: python manage.py createsuperuser.
  6. Copy the .env.example file to .env, and edit it to match your database.
  7. Start the development server: python manage.py runserver

Configure Twilio to call your webhooks

You will also need to configure Twilio to call your application when calls are received

You will need to provision at least one Twilio number with voice capabilities so the application's users can take surveys. 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.

Open a number configuration

Next, edit the "Request URL" field under the "Voice" section and point it towards your ngrok-exposed application /automated-survey/first-survey/ route. Set the HTTP method to POST. If you are trying the Heroku application you need to point Twilio to http://<your-app-name>.herokuapp.com/automated-survey/first-survey/. See the image below for an example:

You can then visit the application at http://localhost:8000/.

Mind the trailing slash.

Webhook configuration

Run the tests

Configure your test database in .env.test. You can then run the tests locally using py.test

$ py.test --cov=automated_survey

About

A sample app for automated phone surveys with Twilio, TwiML, Python and Django

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 88.1%
  • HTML 10.3%
  • Other 1.6%