Skip to content

shxpark/automated-survey-django

 
 

Repository files navigation

Automated surveys (Django)

Build Status

Use Twilio to conduct automated phone surveys.

Read the full tutorial!

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 it. 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, we recommend Postgres.app. After installing, run createdb surveys;.
    • If Postgres is already installed locally, you can just run createdb surveys from a terminal.
  4. Copy the .env.example file to .env, and edit it to match your database.

  5. Run the migrations with python manage.py migrate.

  6. Optionally create a superuser so you can access the Django admin: python manage.py createsuperuser.

  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. To be able to do this you would need to 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 it to work with your application. Open the number management page and open a number's configuration by clicking on it. Open a number's 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 images below as an example on how to do it:

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

Mind the trailing slash.

Webhook Voice configuration

The same endpoint for Voice is being used for Messaging, so you can repeat this step on the Messaging section. Webhook SMS configuration

Run the tests

Configure your test database by editing .env.test file. You can then run the tests locally using py.test

$ py.test --cov=automated_survey

Meta

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

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 90.0%
  • HTML 8.7%
  • Other 1.3%