Giter Site home page Giter Site logo

rickyrobinett / automated-survey-laravel Goto Github PK

View Code? Open in Web Editor NEW

This project forked from twiliodeved/automated-survey-laravel

0.0 2.0 0.0 1.48 MB

Sample application demonstrating automated voice surveys in PHP with laravel

PHP 99.02% ApacheConf 0.57% JavaScript 0.40%

automated-survey-laravel's Introduction

Automated surveys using Laravel

Build Status

This application demostrates how to use Twilio and TwiML to perform automatic phone surveys.

Deploying to Heroku

Deploy

Running locally

The web application

  1. Clone the repository, copy the included env.example as .env and customize it to your needs. The application only requires a running database
  2. Use composer to install the app's dependencies by running composer install in the repo's root
  3. Run the database migrations using php artisan migrate. If the database is configured correctly in .env this will get you a working database
  4. In order to run the application you will need at least one survey. The repository includes a sample survey you can use to test the application. Run php artisan surveys:load bear_survey.json to load a survey about bears into your database. If you have deployed to Heroku using the button you already have this survey loaded.

Configuring Twilio to call your application

Exposing the app via ngrok

For this demo it's necessary that your local application instance is accessible from the Internet. The easiest way to accomplish this during development is using ngrok. If you're running OS X you can install ngrok using Homebrew by running brew install ngrok. First you will need to run the application:

php artisans serve

After this you can expose the application to the wider Internet by running (port 8000 is the default for Laravel):

ngrok 8000

Configuring Twilio's webhooks

You will need to provision at least one Twilio number with voice capabilities so the application's users can take surveys. You can do that 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 /first_survey route. Set the HTTP method to GET. If you have are trying out the Heroku application you need to point Twilio to http://<your-app-name>.herokuapp.com/first_survey. See the image below for an example:

Webhook configuration

Give your number a call, answer the questions about bears and then go to:

http://localhost:8000/survey/1/results

The results of the survey should be there.

Running the tests

The tests interact with the database so you'll first need to migrate your test database. First, set the DATABASE_URL_TEST and then run:

php artisan migrate

The tests then can be run using

phpunit

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.