VoxImplant Web SDK Reference

New version is here! Check documentation for details.


Current version 3.6.363 Check release notes for details.

Web SDK allows you to embed voice and video communication into your web applications.

Browser

To start using VoxImplant Web SDK you need to add javascript library to your webpage:

<script type="text/javascript" src="//cdn.voximplant.com/voximplant.min.js"></script>

It will load the most recent release of Web SDK. If you want to use particular release you can specify it:

<script type="text/javascript" src="//cdn.voximplant.com/voximplant-1.0.min.js"></script>

Node.js

Use npm to install the SDK into your project

npm install voximplant-websdk

and then

var VoxImplant = require('voximplant-websdk');

to use it.

Initialization

After Web SDK is loaded you can use VoxImplant.getInstance function to get VoxImplant.Client instance and
initialize it using init function. See the example below:

var vox = VoxImplant.getInstance();
vox.init({micRequired: true});
vox.addEventListener(VoxImplant.Events.SDKReady, handleSDKReady);

After SDK is initialized SDKReady event will be fired. You can start using SDK functions only after this event. Use connect function to establish connection with VoxImplant Cloud:

vox.connect();
vox.addEventListener(VoxImplant.Events.ConnectionEstablished, handleConnectionEstablished);
vox.addEventListener(VoxImplant.Events.ConnectionFailed, handleConnectionFailed);
vox.addEventListener(VoxImplant.Events.ConnectionClosed, handleConnectionClosed);

function handleConnectionEstablished() {
    if (typeof console != "undefined") console.log("Connected to VoxImplant:" +vox.connected());
}

function handleConnectionFailed(e) {
    if (typeof console != "undefined") console.log("Connection to VoxImplant failed:" +e.message);
}

Authorization

After the connection has been established client should be authorized:

vox.addEventListener(VoxImplant.Events.AuthResult, handleAuthResult);
vox.login("voximplant_username", "voximplant_password");

function handleAuthResult(e) {
    //console.log("AuthResult: "+e.result);
    if (e.result) {
        // authorized successfully - can make and receive calls
        var currentCall = vox.call("phone_number");
        // need to handle call events - register handlers
        currentCall.addEventListener(VoxImplant.CallEvents.Connected, handleCallConnected);
        currentCall.addEventListener(VoxImplant.CallEvents.Failed, handleCallFailed);
        currentCall.addEventListener(VoxImplant.CallEvents.Disconnected, handleCallDisconnected);
    } else {
        // authorization failed
    }
}

function handleCallConnected() {
    // Successful call
}

...

Instant Messaging and Presence

VoxImplant developers can build messaging apps using Web SDK, but this functionality should be enabled for application first. There is number of functions and events available for that, for example: