Functions

VoxEngine.addEventListener(appevent, handler)

void

Add handler for specific event generated by application in specific state

Parameters
  • appevent: Function

    Event class (i.e. AppEvents.CallAlerting)

  • handler: Function

    Handler function. A single parameter is passed - object with event information

VoxEngine.callConference(conferenceId, callerid, displayName, headers)

Call

Make a call to system-wide conference

Parameters
  • conferenceId: String

    Id of the conference

  • callerid: String (optional)

    CallerId

  • displayName: String (optional)

    Optional printable name of callerid

  • headers: Object (optional)

    Optional SIP headers to be passed with call to conference. Custom header names have to begin with the 'X-' prefix. The "X-" headers could be handled by a SIP phone or WEB SDK (e.g. see the incomingCall event). Example: {'X-header':'value'}

Returns

VoxEngine.callPSTN(number, callerid)

Call

Start outgoing call to the specified PSTN number. Calls more expensive than 20 cents per minute and calls to Africa are blocked by default for security reasons. Please contact us at support@voximplant.com to enable them.

Parameters
  • number: String

    PSTN number to start call to in international format (E.164)

  • callerid: String (optional)

    Caller ID that will be displayed to the called user. Can be only one of the phone numbers that were bought in the VoxImplant. If not specified, default system Caller ID is used

Returns

VoxEngine.callSIP(to, callerid, displayName, password, authUser, extraHeaders, video, outProxy)

Call

Start outgoing call to the external SIP system. Optional parameters can be specified as positional arguments or as a single object with property names corresponding to parameter names. If object syntax is used, following additional parameters are available:

  • regId, identifier of a Voximplant SIP registration to use for this outbound call
  • For example:
    var call = VoxEngine.callSIP("+71234567890", {regId: 12345});

    Parameters
    • to: String

      SIP URI to make call to

    • callerid: String (optional)

      CallerID that will be displayed to the called user. If not specified, "anonymous@appname.accname.voximplant.com" string will be sent, where "appname" is the Voximplant application name and "accname" is the Voximplant account name.

    • displayName: String (optional)

      Name of calling user, that will be displayed to the called user

    • password: String (optional)

      Password for SIP Authentication

    • authUser: String (optional)

      Username for SIP Authentication. If not specified, callerid is used as username for authentication

    • extraHeaders: Object (optional)

      Optional custom parameters (SIP headers) that should be passed with call (INVITE) message. Custom header names have to begin with the 'X-' prefix. The "X-" headers could be handled by a SIP phone or WEB SDK (e.g. see the incomingCall event). Example: {'X-header':'value'}

    • video: Boolean (optional)

      Specifies if call should have video support. Please note that price for audio-only and video calls is different!

    • outProxy: String (optional)

      Specifies outbound proxy

    Returns

    VoxEngine.callUser(username, callerid, displayName, extraHeaders, video)

    Call

    Start outgoing call to the specified Voximplant user. The JavaScript scenario that uses this method and user being called should be both associated with the same Voximplant application.

    Example

    Minimal example:

     VoxEngine.addEventListener(AppEvents.CallAlerting, function(e){
       var out = VoxEngine.callUser("username", "String-to-display-on-called-user-device-as-a-caller-name");
     }
    
    Parameters
    • username: String

      Name of the Voximplant user to call

    • callerid: String

      CallerID of the calling user, that will be displayed to the called user. Note that usage of whitespaces is not allowed. Normally it's some phone number that can be used to call back.

    • displayName: String (optional)

      Name of the calling user, that will be displayed to the called user. Normally it's a human-readable version of CallerID, ex a person name.

    • extraHeaders: Object (optional)

      Optional custom parameters (SIP headers) that should be passed with call (INVITE) message. Custom header names have to begin with the 'X-' prefix. The "X-" headers could be handled by a SIP phone or WEB SDK (e.g. see the incomingCall event). Example: {'X-header':'value'}

    • video: Boolean (optional)

      Specifies if call should have video support. Please note that price for audio-only and video calls is different!

    Returns

    VoxEngine.callUserDirect(incomingCall, username, callerid, displayName, extraHeaders)

    Call

    Start outgoing call to the specified Voximplant user in peer-to-peer mode. The JavaScript scenario that uses this method and user being called should be both associated with the same Voximplant application. Audio playback and recording will not make any effect. P2P mode is available only for calls between SDKs.

    Example

    Minimal example

     VoxEngine.addEventListener(AppEvents.CallAlerting, function(e) {
        var inc = e.call;
        var out = VoxEngine.callUserDirect(inc, "Username", "someCallerId");
      }
    
    Parameters
    • incomingCall: Call

      Incoming call that needs to be forwarded

    • username: String

      Name of the Voximplant user to call

    • callerid: String

      CallerID of calling user, that will be displayed to the called user. Note that usage of whitespaces is not allowed. Normally it's some phone number that can be used to call back.

    • displayName: String (optional)

      Name of the calling user, that will be displayed to the called user. Normally it's a human-readable version of CallerID, ex a person name.

    • extraHeaders: Object (optional)

      Optional custom parameters (SIP headers) that should be passed with call (INVITE) message. Custom header names have to begin with the 'X-' prefix. The "X-" headers could be handled by a SIP phone or WEB SDK (e.g. see the incomingCall event). Example: {'X-header':'value'}

    Returns

    VoxEngine.customData(cData)

    void

    Set or get custom string associated with call session. It can be later obtained from Call History using HTTP API.

    Parameters
    • cData: String|undefined

      Custom session data to set. Maximum size is 200 bytes.

    VoxEngine.easyProcess(call1, call2, onEstablishedCallback)

    void

    Adds all default event listeners to pass signaling information between two calls. You could check what is inside this method.

    Example

    VoxEngine.addEventListener(AppEvents.CallAlerting, function(e) {
        var inc = e.call;
        var out = VoxEngine.callPSTN("+13115552368");
        VoxEngine.easyProcess(inc, out);
     });
    
    Parameters
    • call1: Call

      Incoming alerting call

    • call2: Call

      Newly created outgoing call

    • onEstablishedCallback: Function (optional)

      Function to be called once call is established. Both call1 and call2 are passed to this function as parameters

    VoxEngine.forwardCallToPSTN(numberTransform, onEstablishedCallback)

    void

    Helper function to forward incoming call to PSTN.

    Parameters
    • numberTransform: Function (optional)

      Optional function used to transform dialed number to international format. This function accepts dialed number and must return phone number in E.164 format

    • onEstablishedCallback: Function (optional)

      Optional function that is invoked after call is established. Both calls (incoming and outgoing) are passed to this function

    VoxEngine.forwardCallToSIP(onEstablishedCallback, video)

    void

    Helper function to forward incoming call to dialed SIP URI.

    Parameters
    • onEstablishedCallback: Function (optional)

      Optional function that is invoked after call is established. Both calls (incoming and outgoing) are passed to this function

    • video: Boolean (optional)

      Specifies if call should have video support. Please note that price for audio-only and video calls is different!

    VoxEngine.forwardCallToUser(onEstablishedCallback, video)

    void

    Helper function to forward incoming call to user of current application. Dialed number is interpreted as username.

    Parameters
    • onEstablishedCallback: Function (optional)

      Optional function that is invoked after call is established. Both calls (incoming and outgoing) are passed to this function

    • video: Boolean (optional)

      Specifies if call should have video support. Please note that price for audio-only and video calls is different!

    VoxEngine.forwardCallToUserDirect(onEstablishedCallback)

    void

    Helper function to forward incoming call to user of current application. Dialed number is interpreted as username. Call is forwarded in P2P mode, so audio playback and recording will not make any effect.

    Parameters
    • onEstablishedCallback: Function (optional)

      Optional function that is invoked after call is established. Both calls (incoming and outgoing) are passed to this function

    VoxEngine.playSoundAndHangup(fileURL)

    void

    Helper function to play sound to incoming call

    Parameters
    • fileURL: String

      URL of audio (mp3) file to play

    VoxEngine.removeEventListener(appevent, handler)

    void

    Remove handler for specific event generated by application

    Parameters
    • appevent: Function

      Event class (i.e. AppEvents.CallAlerting)

    • handler: Function (optional)

      Handler function. If not specified, all event listeners are removed

    VoxEngine.sendMediaBetween(mediaUnit1, mediaUnit2)

    void

    Start sending media from mediaUnit1 to mediaUnit2 and vice versa

    Is a shortcut for
    mediaUnit1.sendMediaTo(mediaUnit2); mediaUnit2.sendMediaTo(mediaUnit1);
    Parameters

    VoxEngine.stopMediaBetween(call1, call2)

    void

    Stop sending media from call1 to call2 and vice versa

    Is a shortcut for
    call1.stopMediaTo(call2); call2.stopMediaTo(call1);
    Parameters
    • call1: Call

      First call

    • call2: Call

      Second call

    VoxEngine.terminate()

    void

    Terminates current call control session