Track NCCO progress
In this code snippet you see how to track how far through an NCCO a caller gets
using the notify action
Example
Prerequisites
npm install expressRun your code
Save this file to your machine and run it:
Prerequisites
Add the following to build.gradle:
Run your code
We can use the application plugin for Gradle to simplify the running of our application. Update your build.gradle with the following:
Run the following gradle command to execute your application, replacing com.vonage.quickstart.kt.voice with the package containing TrackNccoProgress:
Prerequisites
Add the following to build.gradle:
Write the code
Add the following to the main method of the TrackNccoProgress file:
port(3000);
/*
* Answer Route
*/
get("/webhooks/answer", (req, res) -> {
String notifyUrl = String.format("%s://%s/webhooks/notification", req.scheme(), req.host());
TalkAction intro = TalkAction.builder("Thanks for calling the notification line.")
.build();
Map<String, String> payload = new HashMap<>();
payload.put("foo", "bar");
NotifyAction notify = NotifyAction.builder()
.payload(payload)
.eventUrl(notifyUrl)
.build();
TalkAction unheard = TalkAction.builder("You will never hear me as the notification URL will return an NCCO")
.build();
res.type("application/json");
return new Ncco(intro, notify, unheard).toJson();
});
/*
* Notification Route
*/
post("/webhooks/notification", (req, res) -> {
res.type("application/json");
return new Ncco(
TalkAction.builder("Your notification has been received, loud and clear.")
.build()
).toJson();
});Run your code
We can use the application plugin for Gradle to simplify the running of our application. Update your build.gradle with the following:
Run the following gradle command to execute your application, replacing com.vonage.quickstart.voice with the package containing TrackNccoProgress:
Prerequisites
Install-Package VonagePrerequisites
composer require slim/slim:^3.8 vonage/clientRun your code
Save this file to your machine and run it:
Prerequisites
pip install vonage python-dotenv fastapi[standard]Run your code
Save this file to your machine and run it:
Prerequisites
gem install sinatra sinatra-contrib rack-contribRun your code
Save this file to your machine and run it:
Try it out
When you call your Vonage Number you will hear a text-to-speech message and receive a request to your notification URL