Tracking Call Details with Bandwidth

10 Nov

1*C9J20eRJ2SUae5EPR0Kp6w

Keeping call analytics with Bandwidth is incredibly easy.

The business of tracking where an incoming sales call originated historically been an incredibly pricey (but necessary) add on. In fact, if you have used Google on your smart phone to call any business in the past years, your call was probably tracked.

Call tracking helps businesses know what ads and searches are effective, pretty straightforward stuff.

Basic Call Tracking Flow

Bandwidth XML (BXML) Basics

Simple BXML for call tracking

Bandwidth XML (BXML for short) makes call control incredibly simple. The above example does a deceivingly large amount of work for us.

  1. Speaks the sentence specified to the original caller.
  2. Creates an outbound call with the specified callerId to each phone number specified in the <PhoneNumber> tag as well as the SIP address.
  3. When the first phone number or SIP Phone (can be softphone or SIP Phone) answers it will connect that endpoint to the original caller.

NodeJS SDK Basics

How to build the XML with the NodeJS SDK

Bandwidth provides a SDK for NodeJS to build up XML to send back when an event happens.

Putting it all together

Putting all this together with a small Express app with SocketIO gives us a very basic demo that will keep track of how many times a number was called along with the latest incoming call number and call duration.

Get the code

Download the source code from the github link.

Set up ngrok

Download ngrok if you have not already. Ngrok is a handy tool that provides an external URL to map to localhost:port.

ngrok running on OSX

The application defaults to port 5000, so launch ngrok http mapping to port 5000:

Be sure to copy the forwarding ngrok url, we’ll need that later to configure the application

Modify bandwidth.json

User creds and baseURL and specified in a json file <bandwidth.json>. Be sure to update the values provided by Bandwidth and ngrok.

  1. userId — UserID from Bandwidth
  2. apiToken — API Token from Bandwidth
  3. apiSecret — API Secret from Bandwidth
  4. baseUrl — ngrok url (from above)
Default values need to be updated

Install and Run

The app is written in node, so following normal conventions just run:

Then visit ‘localhost:5000’ and call the number on the screen to see some basic call tracking!

Live Demo

Check out a live demo at calltracking.bwdemos.com

Subscribe to Bandwidth

If for some reason you don’t already have an account to get started with the Bandwidth Application Platform, simply fill out the form here and one of our awesome support staff will get you setup in no time!

Dan Tolbert
Dan Tolbert
dtolbert@bandwidth.com

Computer Nerd. Beer Snob. Music Enthusiast. Idea Machine. Developer Evangelist for Bandwidth.com. Telecommunications Expert.

No Comments

Post A Comment