The purpose of the Demo application is to demonstrate how to integrate the Nexmo API with the CommsRouter.
The demo application exposes a public REST API (WebHooks), which Nexmo can call into, in order to notify us when a new incoming call arrives.
When a new WebHook call arrives to the Demo app, it creates a Task in the CommsRouter. The task contains a WebHook where the CommsRouter will callback us when an agent is found. When the CommsRouter calls the Task's WebHook, the Demo app then takes the agent's address and creates a voice call to the agent. Then the two call legs are put in a dedicated Nexmo conversation. When the agent's call leg ends, the task is marked as completed in the CommsRouter.
In order to use the demo application you'll need to:
- Create a Nexmo account
- Create a Nexmo Voice Application
- Buy one number from Nexmo and associate it with the Nexmo Voice Application
Here is a tutorial where you can see how to:
- Create a Voice Application
- Buy a Phone Number
- Link the Phone Number to a Nexmo Application
Before installing the demo app, you'll need to make some configuration changes.
Find application.properties file which has the following structure:
app.callbackBaseUrl=
app.nexmoCallbackBaseUrl=
app.phone=
app.musicOnHoldUrl=
comms.routerUrl=
comms.routerId=
comms.planId=
comms.queueId=
nexmo.appId=
nexmo.appPrivateKey=
Please put the values inside the application properties as follow:
-
app.nexmoCallbackBaseUrl Base URL to the server where the demo app is served from. This URL will be used from the Nexmo server for invoking web hooks. For example http://host:port/demo-app-root/api
-
app.callbackBaseUrl Base URL to the server where the demo app is served from. This URL will be used from the CommsRouter web app for invoking tasks' callback hooks. For example http://host:port/demo-app-root/api
-
app.phone This is the number you bought from Nexmo and associated it with your voice application
-
app.musicOnHoldUrl This is an URL to the mp3 file to stream to the customer until an available Agent is found.
-
comms.routerUrl This the base URL to the CommsRouter REST API. For example http://commsrouterhost:port/comms-router-web-api-no-auth/api
-
comms.routerId This is the id of the router object in the CommsRouter
-
comms.planId This is the id of the plan object in the CommsRouter
-
comms.queueId This is the id of the default queue object in the CommsRouter
-
nexmo.appId This is the app-id from your Nexmo Voice application
-
nexmo.appPrivateKey This is the filename (PEM file) with the private key from your Nexmo voice application. This PEM file must be in the same directory where application.properties file is.
Then add a system property of the JVM with key comms.demo.app.config.path that will tell the app where to find the application.properties file.
Ex. java -Dcomms.demo.app.config.path=/configDir
.
Ex. With Tomcat JVM properties are set like this:
- UNIX:
$CATALINA_BASE/bin/setenv.sh
export CATALINA_OPTS="$CATALINA_OPTS -Dcomms.demo.app.config.path=/configDir"
- Windows:
%CATALINA_BASE%\bin\setenv.bat
set CATALINA_OPTS=%CATALINA_OPTS% -Dcomms.demo.app.config.path=c:\configDir
Copy demo-application/target/demo-application*.war to tomcat's webapps folder
Demo application does not use authentication, so it requires instance of CommsRouter with turned off authentication. Before using the demo app, you'll need to create Router, Queue, Agent and Plan objects in the CommsRouter via its REST API.
Router, Queue, Plan objects, must be with an ID equal to the id specified in the comms.routerId parameter in application.properties file.
An Agent must have a valid address (phone number) where the Nexmo will make a voice call.