This is a demo application built in Node JS using Express.js and the Vonage Node SDK, but you could build equivalent versions of this app in a different programming language using one of Vonage's other Server SDKs.
To run this demo, you will need:
- A Vonage Developer account
- Node.js installed
- (Optional) Ngrok installed (only required if you want to run the Video demo and connect to the video call from a separate device)
You'll need to set up a Vonage application to manage the capabilities and obtain the API credentials for this app.
-
Log onto the Vonage Developer Dashboard
-
Go to the Applications page and click on the 'Create a new application' button
-
Generate a private key for the application by clicking on the 'Generate public and private key' button. Download the
private.key
file and keep it somewhere safe. -
Under 'Capabilities', enable the application for Voice, Messages, and Video by toggling the switches to 'on' (for Messages, you will need to fill in the 'Inbound URL' and 'Status URL' fields, but you can just put some dummy urls here, since we won't be using the webhooks)
-
Click on the 'Generate new application' button at the bottom. This will generate and Application ID for the Vonage application; make a note of this for later.
-
(Optional) For the SMS and/or Voice parts the demo, you will need a number enabled for SMS and/or Voice. Go to the Buy Numbers page and purchase a number with both SMS and/or Voice capabilites (depending on whether you want to run either part of the SMS part of the demo, the Voice part, or both). You can then link this number in the Dashboard to the Vonage application you just created by accessing that application under Applications page and licking on the 'Link' button next to the number. (Note that to send SMS in India, numbers need to be registered. See India SMS Features and Restrictions)
-
(Optional) The WhatsApp part of the demo application uses the Messages Sandbox, so you don't need to set up your own WhatsApp Business Account (WABA). However, you will need to allow-list the number that you want to send WhatsApp messages to within the Sandbox. To do this go to the Messages Sandbox page in the Dashboard and follow the instructions there to allow-list your number. Make a note of the WhatsApp Sandbox number for later.
-
Open Terminal and navigate to wherever you want to clone the repository.
-
Clone the repository
git clone https://github.com/Vonage-Community/demo-messages_voice_video-node-hack_this_fall.git
-
Change directory (
cd
) into the root directory of the cloned repository and install the dependenciesnpm install
-
Copy or move the
private.key
file you downloaded earlier the root directory of this demo application -
Copy or rename the
.env-sample
file to.env
and update the file with your Vonage credentials:VONAGE_APPLICATION_ID
. This is the Application ID you generated earlier when creating the Vonage ApplicationVONAGE_VIRTUAL_NUMBER
. If you completed step 6 of Setting up your Vonage Application, this is the Vonage virtual numer you purchased.VONAGE_SANDBOX_NUMBER
. If you completed step 7 of Setting up your Vonage Application, this is the WhatsApp number for the Vonage Messages Sandbox
-
Start up Ngrok
ngrok http 3000
-
Copy the Ngrok
Forwarding
URL and set this in the.env
file as the value forTUNNEL_URI
-
In a separate Terminal tab, start the Node application
node app.js
-
In your browser, navigate to
localhost:3000