SIGN UP

Your first Voximplant application

Welcome to Voximplant! This tutorial will help you to create your first Voximplant application.
You will need to complete 3 simple steps:

 

  1. Create your first call scenario
  2. Configure your Voximplant account
  3. Make call using WebSDK 

 

Please note that you need to go through all 3 steps to make your first call

1. Create your first call scenario

All call control scenarios for Voximplant are written in JavaScript.

To begin, we'll go over a simple example: someone makes a call. Then Voximplant answers it and plays a voice message.
The code for this case is pretty straightforward:

VoxEngine.playSoundAndHangup("http://cdn.voximplant.com/hello.mp3");

You need to go to the Scenarios tab of the Voximplant control panel and add the scenario with the text above.

To learn more about how VoxImpant call control scenarios work, you can see this set of tutorials.

 

2. Configure your Voximplant account

To start using Voximplant, you need to create a user account and an application.

Each user can log into certain applications (you will need to define which ones) using the Voximplant Web SDK or SIP and make calls using the rules defined in these applications.

To create a user, open Users tab in control panel, press Create User button and enter a name and password for the new user.

An application is a set of rules that define which call processing scenarios are applied to each call. You will need to go to the Applications tab of the Voximplant control panel and create a new application. Please note that the name can only contain alphanumeric characters, dashes, and underscores.

You will also need to select and move the user you created earlier from Available to Assigned in this dialog.

After the application has been created, you will need to create a rule in it. Enter the edit application dialog, and in the Rules tab, create a new rule. You don't need to modify any patterns; just enter a name and select and move the scenario you created in step 1 from Available to Assigned.

To learn more about the overall architecture of applications, users, and rules in Voximplant, you can refer to this documentation.

 

3. Make a call using WebSDK

Now you need to create a simple HTML page that contains the following code:

<html>
<head>
  <script type="text/javascript" 
          src="//cdn.voximplant.com/edge/voximplant.min.js"></script>
  <script type="text/javascript">
    let initialized = false,
      loggedIn = false,
      connected = false;
    const voxImplant = VoxImplant.getInstance();
    // Please, change this data before go.
    const appUser = 'APPLICATIONUSER',
      appUserPassword = 'SECUREPASSWORD',
      appName = 'VOXAPPLICATION',
      account = 'ACCOUNT';



    function logMessage(msg) {
      document.getElementById("log").innerHTML += `${msg}<br/>`;
    }

    function makeCall() {
      // Number isn't important - our simple VoxEngine script
      // will just playback the audio file
      const call = voxImplant.call("0000");
      // Add event listeners for call events
      call.on(VoxImplant.CallEvents.Connected, () => {
        logMessage('Call Connected')
      });
      call.on(VoxImplant.CallEvents.Failed, e => {
        logMessage(`Call Failed. Code: ${e.code} Reason: ${e.reason}`);
      });
      call.on(VoxImplant.CallEvents.Disconnected, () => {
        logMessage('Call Disconnected');
      });
    }

    function connectNow() {
      voxImplant.init()
        .then(function () {
          initialized = true;
          logMessage('VoxImplant SDK ready');
          // Connection with VoxImplant Cloud can be established now
          return voxImplant.connect();
        })
        .then(function () {
          connected = true;
          logMessage('Connection established');
          voxImplant.on(VoxImplant.Events.ConnectionClosed, (e) => {
            logMessage('Connectio closed');
          });
          voxImplant.on(VoxImplant.Events.ConnectionFailed, (e) => {
            logMessage('Connectio failed');
            logMessage(JSON.stringify(e));
          });
          // Authorization required before we can use other functions
          return voxImplant.login(
            `${appUser}@${appName}.${account}.voximplant.com`,
            appUserPassword);
        })
        .then(function () {
          logMessage(`AuthResult: ${e.result}`);
          logMessage('Now you can make a call');
          if (e.result) {
            // Logged in successfully
            loggedIn = true;
          } else {
            logMessage('Authorization failed.');
            logMessage('Please specify correct username and password');
          }
        })
        .catch(function (e) {
          logMessage('Oops. We have some error during connection!');
          logMessage(JSON.stringify(e));
        })
    }
  </script>
</head>
<body>
<a href="javascript:connectNow()">Connect</a><br/>
<a href="javascript:testCall()">Make Call</a><br/>
<textarea style="height: 400px" id="log"></textarea>
</body>
</html>
Get your free developer account or talk with our sales team to learn more about Voximplant solutions
SIGN UP
Contact sales

Please complete this field.

Please complete this field.

Please complete this field.

Choose the solution

Please complete this field.

Please complete this field.