JavaScript

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 Vonage CLI.

If you want to carry out tasks such as creating applications, purchasing Vonage numbers and so on, you will need to install the Vonage CLI. As the Vonage CLI requires node.js you will need to install node.js first.

To make sure node.js is installed, please run the following command in the terminal:

node -v

Follow the steps outlined on the Getting Started with Vonage CLI page to install and configure the command line.

The Vonage CLI allows you to install plugins to add additional capabilities. For this tutorial you will need the Conversations plugin.

To install the plugins, run the following commands:

vonage plugins:install @vonage/cli-plugin-conversations

If you are planning to use JavaScript to develop your application, you'll need to install (or update) the latest version of the Client SDK.

Create a new project directory and change into it. Then run the following command:

npm init npm install nexmo-client --save

This will install the Client SDK into the node_modules directory within your project folder.

If you already have the Client SDK installed the above command will upgrade your Client SDK to the latest version.

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.