close search

Hello World

This hello world procedure will get you a basic browser-based audio/video chat in five minutes.


Getting an API key, session ID, and token

  1. Sign up for a TokBox Account.
    Free for thirty days. No credit card required.
  2. Use your credentials to log in to your TokBox Account.
  3. Create a project by clicking add project, typing a name, and clicking view project.
  4. Copy the API Key value and paste it into a text file.
  5. Within the Project Tools section, click Create Session ID.
  6. Copy the session ID from the box below the Create Session ID button and paste it into a text file.
  7. Within the Generate Token area, click Generate token.
    Make sure that Publisher is selected in the Role list box.
  8. Copy the token value from the box below the Generate token button and paste it into a text file.

Implementing a basic audio/video conference

  1. Add the following code to a web page served by your web server.
        <script src="" charset="utf-8"></script>
        <script charset="utf-8">
          var apiKey = 'YOUR-API-KEY';
          var sessionId = 'YOUR-SESSION-ID';
          var token = 'YOUR-TOKEN';
          var session = OT.initSession(apiKey, sessionId)
            .on('streamCreated', function(event) {
            .connect(token, function(error) {
              var publisher = OT.initPublisher();
  2. Replace YOUR-API-KEY, YOUR-SESSION-ID, and YOUR-TOKEN with the values from your TokBox Account.

    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 deploy one of our server SDKs to generate these values dynamically.

  3. Save the file and load it in a supported browser.
  4. When prompted, grant access to your camera and microphone.
  5. The video from your webcam should appear in the browser.
  6. Mute your speaker.
  7. Copy the URI in the browser to your Clipboard.
  8. Open a new tab.
  9. Paste the URI into the new tab. Now you should have two videos.
    If you have a public address, share the path with a friend for a real video chat!

Tip: Use the OpenTok Playground tool to join this session as a participant to view streams published from your test device and poke around to better understand OpenTok APIs

What just happened?

What next?

Keep building

You can keep building on the JavaScript code above. Visit OpenTok Basics, Developer Guides, and Tutorials to find out how to add more functionality. Or use OpenTok Playground to test OpenTok platform capabilities without having to write any code

Get session IDs and tokens dynamically

Deploy one of our server SDKs to generate unique session IDs and per-user tokens on demand (required for a production app). Download a sample app in the language of your choice for a big head start.

Didn't find your favorite language? You can also access our REST API directly.