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.
Bandwidth XML (BXML) Basics
Bandwidth XML (BXML for short) makes call control incredibly simple. The above example does a deceivingly large amount of work for us.
- Speaks the sentence specified to the original caller.
- Creates an outbound call with the specified callerId to each phone number specified in the <PhoneNumber> tag as well as the SIP address.
- 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
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.
The application defaults to port 5000, so launch ngrok http mapping to port 5000:
ngrok http 5000
Be sure to copy the forwarding ngrok url, we’ll need that later to configure the application
User creds and baseURL and specified in a json file <bandwidth.json>. Be sure to update the values provided by Bandwidth and ngrok.
- userId — UserID from Bandwidth
- apiToken — API Token from Bandwidth
- apiSecret — API Secret from Bandwidth
- baseUrl — ngrok url (from above)
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!
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!