Track NCCO progress

In this code snippet you see how to track how far through an NCCO a caller gets using the notify action

Prerequisites

Create an Application

Check out Getting Started with Vonage CLI for more information on how to install and configure the CLI.

Use the following command to create a Vonage application:

vonage apps create 'Your application'✅ Creating ApplicationSaving private key ... Done!Application createdName: Your applicationApplication ID: 00000000-0000-0000-0000-000000000000Improve AI: OffPrivate/Public Key: SetCapabilities: None Enabled

Once you have the application, you then need to add the voice capabilities; make sure you replace the webhook URLs with your own:

vonage apps capabilities update 00000000-0000-0000-0000-000000000000 voice \ --voice-answer-url='https://example.com/webhooks/voice/answer' \ --voice-event-url='https://example.com/webhooks/voice/event' \ --voice-fallback-url='https://example.com/webhooks/voice/fallback'✅ Fetching Application✅ Adding voice capability to application 00000000-0000-0000-0000-000000000000Name: Your applicationApplication ID: 00000000-0000-0000-0000-000000000000Improve AI: OffPrivate/Public Key: SetCapabilities: VOICE: Uses Signed callbacks: On Conversation TTL: 41 hours Leg Persistence Time: 6 days Event URL: [POST] https://example.com/webhooks/voice/event Answer URL: [POST] https://example.com/webhooks/voice/answer Fallback URL: [POST] https://example.com/webhooks/voice/fallback

The application is then created and has the required capabilities. Creating an application and adding application capabilities are covered in detail in the application overview.

Rent a Number

You can rent a number using the Vonage CLI. The following command searches for an available number in the United States:

vonage numbers search US✅ Searching for numbersThere is 1 number available for purchase in United StatesNumber Type Features Monthly Cost Setup Cost----------- ------ --------------- ------------ ----------16127779311 Mobile MMS, SMS, VOICE €0.90 €0.00Use vonage numbers buy to purchase.

Use this command to purchase a number:

vonage numbers buy US 16127779311 ✅ Searching for numbersAre you sure you want to purchase the number 16127779311 for €0.90? [y/n] y✅ Purchasing numberNumber 16127779311 purchasedNumber: 16127779311 Country: 🇺🇸 United StatesType: MobileFeatures: MMS, SMS, VOICEMonthly Cost: €0.90Setup Cost: €0.00Linked Application ID: Not linked to any applicationVoice Callback: Not SetVoice Callback Value: Not SetVoice Status Callback: Not Set

Specify an alternative two-character country code to purchase a number in another country.

Now that you have both an application and a number, you need to link them together.

vonage apps numbers link 00000000-0000-0000-0000-000000000000 16127779311✅ Fetching ApplicationFetching Owned numbers [===============================================] 1/1 100%Number linkedNumber: 16127779311Country: 🇺🇸 United StatesType: Toll-freeFeatures: MMS, SMS, VOICEMonthly Cost: Not SetSetup Cost: Not SetLinked Application ID: 00000000-0000-0000-0000-000000000000Voice Callback: appVoice Callback Value: 00000000-0000-0000-0000-000000000000Voice Status Callback: Not Set

Example

Prerequisites

Write the code

Add the following to notify-a-call.js:

View full source

Run your code

Save this file to your machine and run it:

node notify-a-call.js

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