Create the answer webhook
When your Vonage number receives a call, the Vonage API platform makes a request to your answer URL webhook endpoint. The webhook must return an NCCO, which is a JSON array of objects. Each object in the array consists of an action that determines how the call should progress.
Note: Find out more about NCCOs here
In this step you will build that webhook. Add the following handler for the /webhooks/answer route:
Beneath it, write the code for the mainMenu function, which creates and returns an NCCO. We have wrapped the code that generates the NCCO in a function so that we can call it from elsewhere in our application, and not only from our answer webhook:
The NCCO this function generates consists of two actions:
talkreads the menu options to the caller using text-to-speech. ThebargeInproperty is set totrue, which enables a user to interrupt the reading of the messageinputwaits for the user to press a key on the phone's keypad and then makes a request to another webhook (defined ineventUrl) with the details of the key they pressed. You will create this webhook in the next step.
Build a Call Menu
Create an interactive voice response (IVR) menu to handle customer calls