.NET

Configure your prerequisites

There are a few prerequisites that you need to complete before you can work through this tutorial. If you've already completed any of them, feel free to skip that step.


You can create a Vonage account via the Dashboard.

Within the Dashboard you can create Applications and purchase Vonage numbers. You can also perform these tasks using the Nexmo CLI.

The Nexmo CLI allows you to carry out many operations on the command line. Examples include creating applications, purchasing numbers, and linking a number to an application.

To install the nexmo CLI with NPM you can use:

npm install nexmo-cli -g

Set up the Nexmo CLI to use your Vonage API Key and API Secret. You can get these from the settings page in the Vonage Dashboard.

Execute the following command in a terminal, replacing API_KEY and API_SECRET with your own:

nexmo setup API_KEY API_SECRET

You must make your webhook accessible to Vonage’s APIs over the public Internet. A straightforward way to achieve this during development without standing up your own server is to use Ngrok. To learn more, read our documentation on Ngrok.

Download and install ngrok, then execute the following command to expose your application on port 3000 to the public Internet:

./ngrok http 3000

If you are a paid subscriber you could type:

./ngrok http 3000 -subdomain=your_domain

NOTE: In this example Ngrok will divert the Vonage webhooks you specified when you created your Vonage application to localhost:3000. Although port 3000 is shown here, you can use any free port that is convenient.

There are two methods for creating a Voice application:

  1. Using the Nexmo CLI
  2. Using the Dashboard

Each of these methods is described in the following sections.

How to create a Voice application using the Nexmo CLI

To create your application using the Nexmo CLI, enter the following command into the shell replacing NGROK_HOST_NAME with the ngrok host that you got when you set up ngrok:

nexmo app:create "AspNetTestApp" http://NGROK_HOST_NAME/webhooks/answer http://NGROK_HOST_NAME/webhooks/events

This command creates a Vonage Application with Voice capability. It configures the Application with your answer and event webhook URLs and generates a private key file private.key, which you should save in your project directory.

The command returns a unique Application ID. Use this Application ID to link your Vonage virtual number to your Application by executing the following:

nexmo link:app VONAGE_NUMBER APPLICATION_ID

This will link that Vonage Virtual Number to your application, which will cause all voice events occurring for that number to be routed to your designated URLs.

How to create a Voice application using the Dashboard

You can create Voice applications in the Dashboard.

To create your application using the Dashboard:

  1. Under Applications in the Dashboard, click the Create a new application button.

  2. Under Name, enter the Application name. Choose a name for ease of future reference.

  3. Click the button Generate public and private key. This will create a public/private key pair and the private key will be downloaded by your browser. Save the private key that was generated.

  4. Under Capabilities select the Voice button.

  5. In the Answer URL box, enter the URL for your inbound calls webhook, for example, http://example.com/webhooks/answer.

  6. In the Event URL box, enter the URL for your call status webhook, for example, http://example.com/webhooks/events.

  7. Click the Generate new application button.

  8. You are now taken to the next step of the Create Application procedure where you should link your Vonage number to the application.

You have now created your application.

NOTE: Before testing your application ensure that your webhooks are configured and your webhook server is running.