JavaScript

Setting Up Authentication

Pull up your blank app.js file in your code editor — most of the remaining steps will involve adding code to this file.

In order to connect to a Vonage Video session, the client will need access to some authentication credentials — an APP ID, Session ID, and Token.

In a production application, these credentials should be generated using a Server SDKs, but to speed things up we will hard code the values for now.

  1. Start by copying the following code block and adding it to your app.js file:

    // replace these values with those generated in your Video API account
    var applicationId = "YOUR_APP_ID";
    var sessionId = "YOUR_SESSION_ID";
    var token = "YOUR_TOKEN";
    
    var session;
    
    initializeSession();
    
  2. Go ahead and replace YOUR_APP_ID with the application ID we generated earlier.

  3. Log into your your Vonage Dashboard and navigate to the Video Playground. It is under Troubleshoot & Learn - Developer Tools - Video - Playground.

  4. Make sure that the "Create a new session" tab is selected at the top.

  5. Select "Yes" under "Have a specific Application ID?"

  6. Paste in the Application ID you generated before into the "Application ID" box that appears.

  7. Leave everything else as-is, and click "Create Session".

  8. On the next page that appears, copy the "SESSION ID".

  9. In app.js, replace YOUR_SESSION_ID with the session ID we just copied.

  10. Click the "Connect" button at the top.

  11. Expand the "Session and token info" section at the top.

  12. Copy the "TOKEN" that was generated

  13. In app.js, replace YOUR_TOKEN with the token we just copied.

  14. Save the app.js file.

Important: You can continue to get the session ID and token values from your Account during testing and development, but before you go into production you must set up a server.

This information will allow our client-side code to talk to the Vonage Video API.

Basic text chat

Follow this tutorial to build basic text chat from scratch using the Vonage Video API. It is the quickest way to build a proof of concept for this functionality on the video platform.

Steps
1
Overview
2
Before You Begin
3
Configure a Vonage Video Application
4
Creating the Project Folders and HTML Template
5
Setting Up Authentication
6
Connecting to the Session
7
Sending a Signal
8
Receiving a Signal
9
Testing your Code in a Browser
10
A little bit of CSS customization
11
Conclusion