Code Monkey home page Code Monkey logo

automated-survey-flask's Introduction

Automated survey for Python - Flask

Learn how to use Twilio Client to conduct automated phone surveys.

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 follow these steps:

  1. Clone this repository and cd into it.

  2. Create and activate a new python3 virtual environment.

    python3 -m venv venv
    source venv/bin/activate
  3. Install the requirements.

    pip install -r requirements.txt
  4. Copy the .env.example file to .env, and edit it to match your database.

  5. Activate Flask development environment

    export FLASK_ENV=development
  6. Run the migrations.

    python manage.py db upgrade
  7. Seed the database.

    python manage.py dbseed

    Seeding will load survey.json into SQLite.

  8. Expose your application to the wider internet using ngrok.

    To actually forward incoming calls, your development server will need to be publicly accessible. We recommend using ngrok to solve this problem.

    ngrok http 5000

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

    http://88b37ada.ngrok.io/voice
  9. Start the development server.

    python manage.py runserver

Once ngrok is running, open up your browser and go to your ngrok URL. It will look like this: http://88b37ada.ngrok.io

That's it!

Configuring 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

The URL you will place the the Request URL field will be as follows. Set the HTTP method to GET. Be sure to change the ngrok hostname to your own.

http://20ee7404.ngrok.io/voice

Similarly, you must configure the SMS messaging section of your Twilio Phone Number To call the /message webhook.

http://20ee7404.ngrok.io/voice

See the images below for an example:

Webhook Voice configuration

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

Mind the trailing slash.

Running the tests

You can run the tests locally through coverage:

  1. Run the tests.

    python manage.py test

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

Meta

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

automated-survey-flask's People

Contributors

dependabot-preview[bot] avatar jefflinwood avatar joliveros avatar kathyguerron avatar maylonpedroso avatar mmena1 avatar mosampaio avatar shyba avatar smendes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

automated-survey-flask's Issues

.env.example file

you mention the .env.example file but there isn't one here. it exists in ivr-recording-laravel but not in this file. this documentation isn't clear; are we supposed to use that file from another project or make our own or... ?

Ran with the following changes

I am using Python3 and the code didn't run directly with the instructions submitted.

Changes:

  1. python3 manage.py runserver
  2. sre_constants.error: bad escape \p at position 7 error because of using python and not python3
  3. ImportError: No module named flask.ext.script -- change to flask_script
  4. Change every other flask.ext. to flask_

Run now and it should be fine. I'm sharing this just in case if someone else was having the same issue as mine.

manage.py failing

running

python manage.py dbseed

gets the error

Traceback (most recent call last):
File "manage.py", line 1, in
from flask.flask_script import Manager
ImportError: No module named flask_script

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.