/survey-node

Automated surveys via text and voice in Node.js with Express and MongoDB

Primary LanguageJavaScriptMIT LicenseMIT

Twilio

Build Status

Automated Surveys. Powered by Twilio - Node.js/Express

Instantly collect structured data from your users with a survey conducted over a voice call or SMS text messages. Learn how to create your own survey in the language and framework of your choice. For a step-by-step tutorial see twilio docs.

Local development

First you need to install Node.js as well as MongoDB

To run the app locally:

  1. Clone this repository and cd into it

    $ git clone git@github.com:TwilioDevEd/survey-node.git
    
    $ cd survey-node
  2. Install dependencies

    $ npm install
  3. Copy the sample configuration file and edit it to match your configuration

    $ cp .env .env.local

    Be sure to set MONGO_URLto your local mongo instance uri for example: mongodb://localhost:27017/surveys where surveys is the db name.

    Run source .env.local to export the environment variables

  4. Run the application

    $ npm start

    Alternatively you might also consider using nodemon for this. It works just like the node command but automatically restarts your application when you change any source code files.

    $ npm install -g nodemon
    $ nodemon index
  5. Expose your application to the wider internet using ngrok. This step is important because the application won't work as expected if you run it through localhost.

    $ npm i -g ngrok
    $ ngrok http 3000

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

    You can read this blog post for more details on how to use ngrok.

    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 using the twilio console.. Once you havea 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.

    Configure Voice

  6. Check it out at http://localhost:3000

Meta

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