This example show how to use Java and BXML to implement a simple call tracking scenario. It uses Java servlets and JSP for a MVC2 approach without a third party MVC frameworks.
This app will:
- Display a list of Calls and Numbers
- Use the Bandwidth Java SDK to order a new phone number - just click the Create Call Tracking Number button
- Expose an endpoint for call processing
- Manage call flow with simple BXML
Install / Configuration
Before installation you must have the following:
- A Bandwidth Application Platform account (sign up here)
- Your App Platform userId, apiToken and apiSecret (see here)
- An application created with the HTTP Method set to GET ([see here](http://ap.bandwidth.com/docs/how-to-guides/configuring-apps-incoming-messages-calls/ to create and application))
To run locally, you must have a running JEE application server. These instructions use Tomcat 8.0.26 (where TOMCAT_HOME is the directory that tomcat is installed).
Step 1 - Set the following environment variables :
- BANDWIDTH_USER_ID (found on the account tab of the developer console)
- BANDWIDTH_API_TOKEN (found on the account tab of the developer console)
- BANDWIDTH_API_SECRET (found on the account tab of the developer console)
- BANDWIDTH_APPLICATION_ID (from the application created above)
Step 2 - Build the app
- From a command line run git clone https://github.com/BandwidthExamples/java-call-tracking.git
- cd java-call-tracking
- mvn clean install
Step 3 - Deploy the app
- cp target/bandwidth-call-tracking-example-1.0-SNAPSHOT.war $TOMCAT_HOME/webapps
- Type http:localhost:8080/bandwidth-call-tracking-example-1.0-SNAPSHOT.war/numbers in browser to see the page below.
Step 4 - Run Ngrok
- cd NGROK_HOME
- ./ngrok http 8080
- Update the App Platform application url to point to the ngrok endpoint, e.g. http://bc257661.ngrok.io/bandwidth-call-tracking-example-1.0-SNAPSHOT/callEvents?direction=incoming
Deploy from IntelliJ
You can also build and run this from IntelliJ as follows (requires installation of IntelliJ 14):
- Create an IntelliJ project from existing source (either the pom.xml or just the source tree)
- Make sure that all of the dependent libraries are included in the project structure
- Create a Tomcat configuration. Ensure that the Web artifact is created
- Start Tomcat with the Run command
- Run ngrok from the command line
- Change the application url to use the ngrok url
Deploy Heroku (work in progress - still working out the dependencies with jetty annotations in a compatible way with tomcat)
This step assumes that you have the Heroku toolbelt installed and an active Heroku account From the command line run the following:
- heroku create
- git add .
- git commit -m "initial deploy"
- git push heroku master
- heroku open
Now update the App Platform application url to point to the Heroku endpoint, e.g.