GithubHelp home page GithubHelp logo

isabella232 / call-tracking-node Goto Github PK

View Code? Open in Web Editor NEW

This project forked from segmentio/call-tracking-node

0.0 0.0 0.0 1.6 MB

Node.js Call Tracking demo app

Home Page: https://www.twilio.com/docs/tutorials/walkthrough/call-tracking/node/express

License: Other

JavaScript 77.46% CSS 0.52% HTML 22.03%

call-tracking-node's Introduction

Call tracking with Twilio, Node.js, and Express

Build Status

This application demostrates how to use Twilio track calls and measure the effectiveness of marketing campaigns. A tutorial walkthrough exists here to help with setting this up.

Running the Project on Your Machine

To run this project on your computer, download or clone the source. You will also need to download and install either Node.js or io.js, both of which should also install npm.

You will also need to sign up for a Twilio account if you don't have one already.

Install Dependencies

Navigate to the project directory in your terminal and run:

npm install

This should install all of our project dependencies from npm into a local node_modules folder.

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 at https://www.twilio.com/user/account/apps/add and use its Sid as the TWIML_APP_SID environment variable wherever you run this app.

Creating a TwiML App

See the end of the "Exposing Webhooks to Twilio" section for details on the exact URL to use in your TwiML app.

Configuration

This application is configured using dotenv. Begin by copying the example .env file to use in this application:

cp .env.example .env

Next, open the .env at the root of the project and update it with credentials from your Twilio account and local configuration. You will also need to set MONGO_URL, which is how we will connect to our database.

This sample application stores data in a MongoDB database using Mongoose. You can download and run MongoDB yourself (OS X, Linux, Windows), or you can use a hosted service like compose.io.

On OS X, the maybe the easiest way to get MongoDB running locally is to install via Homebrew.

brew install mongodb

You should then be able to run a local server with:

mongod

By default, there will be a local database running that's not password protected. In your .env file, set MONGO_URL to mongodb://127.0.0.1/calltracking.

Then, you'll need a SEGMENT_WRITE_KEY. This is the key that lets Segment (sign up for free), a customer data platform, know which project to collect analytics data from. You can find your SEGMENT_WRITE_KEY by following this help article.

You should now be all set to run the app locally!

Running the Project

To launch the application, you can use node . in the project's root directory. 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 .

Running Tests

Basic functional tests (requires local MongoDB) can be run with:

npm test

Exposing Webhooks to Twilio

To test your application locally with a Twilio number, we recommend using ngrok. Use ngrok to expose a local port and get a publicly accessible URL you can use to accept incoming calls or texts to your Twilio numbers.

The following example would expose your local Node application running on port 3000 at http://chunky-danger-monkey.ngrok.io (note that reserved subdomains are a paid feature of ngrok):

ngrok http -subdomain=chunky-danger-monkey 3000

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

License

MIT

call-tracking-node's People

Contributors

atbaker avatar kwhinnery avatar lambtron avatar molinto avatar mplacona avatar nebtrx avatar rjatkinson2 avatar

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.