Use Twilio to conduct automated phone surveys.
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:
-
Create a new virtual environment:
- If using vanilla virtualenv, run
virtualenv venv
and thensource venv/bin/activate
. - If using virtualenvwrapper, run
mkvirtualenv automated-surveys
.
- If using vanilla virtualenv, run
-
Install the requirements with
pip install -r requirements.txt
. -
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.
- If on a Mac, we recommend
Postgres.app. After installing, run
-
Copy the
.env.example
file to.env
, and edit it to match your database. -
Run the migrations with
python manage.py migrate
. -
Optionally create a superuser so you can access the Django admin:
python manage.py createsuperuser
. -
Start the development server:
python manage.py runserver
.
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.
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 running the application
in production somewhere, you need to point Twilio to
http://<your-app-name>.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.
The same endpoint for Voice is being used for Messaging, so you can repeat this step on the Messaging section.
Configure your test database by editing .env.test
file. You can then run the tests locally using py.test
$ py.test automated_survey/tests/ --cov=automated_survey
- No warranty expressed or implied. Software is as is. Diggity.
- MIT License
- Lovingly crafted by Twilio Developer Education.