Skip to content

enterstudio/call-tracking-node

 
 

Repository files navigation

Twilio

Call tracking

Build Status

Call Tracking helps you measure the effectiveness of different marketing campaigns. By assigning a unique phone number to different advertisements, you can track which ones have the best call rates and get some data about the callers themselves. For a step-by-step tutorial see twilio docs to help with setting this up.

Create a TwiML App

This project is configured to use a TwiML App, which allows us to easily set the voice URLs for all Twilio phone numbers we purchase in this app.

Create a new TwiML app and use its Sid as the TWILIO_APP_SID environment variable wherever you run this app.

Creating a TwiML App

See the end of the "Local development" section for details on the exact URL to use in your TwiML app.

Once you have created your TwiML app, configure your Twilio phone number. If you don't have a Twilio phone number yet, you can purchase a new number in your Twilio Account Dashboard.

Local development

First you need to install

  1. First clone this repository and cd into its directory:

    git clone git@github.com:TwilioDevEd/browser-calls-node.git
    
    cd browser-calls-node
  2. Install dependencies:

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

    $ cp .env.example .env

    You can find your TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN in your Twilio Account Settings. You will also need a TWILIO_PHONE_NUMBER, which you may find here.

    Run source .env 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 ./bin/www
  5. To actually forward incoming calls, your development server will need to be publicly accessible. We recommend using ngrok to solve this problem.

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

    http://88b37ada.ngrok.io/call/connect

Run the tests

You can run the tests locally by typing

```bash
npm test
```

Try it out

In your Twilio app configuration you'll need to set http://<your-ngrok-domain>.ngrok.io/lead as the callback URL. Open the application and then click the "App configuration" button.

app configuration button screenshot

The button will take you to your TwiML call tracking application. Under "Voice" you will find a "Request URL" input box. There you should put the URL to the application's lead resource (e.g http://<your-ngrok-domain>.ngrok.io/lead).

webhook configuration

Meta

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

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 80.8%
  • HTML 18.6%
  • CSS 0.6%