Constructs new call.

Methods

addEventListener(callevent, handler)

void

Add handler for specific event generated by call in specific application state

Parameters
  • callevent: Function

    Event class (i.e. CallEvents.Connected)

  • handler: Function

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

answer(extraHeaders, parameters)

void

Answer incoming call

Parameters
  • extraHeaders: Object (optional)

    Optional custom parameters (SIP headers) that should be passed with answer message. Parameter names must start with "X-" to be processed by application

  • parameters: Object (optional)

    Optional custom parameters

callerid()

String

Returns Caller ID for call

Returns
  • String

customData(cData)

String

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

Parameters
  • cData: String|undefined

    Custom call data to set

Returns
  • String

decline(code, extraHeaders)

void

Reject incoming call

Parameters
  • code: Number (optional)

    SIP status code

  • extraHeaders: Object (optional)

    Optional custom parameters (SIP headers) that should be passed with answer message. Parameter names must start with "X-" to be processed by application

detectProgressTone()

void

Detect progress tone on outgoing call

detectVoicemailPrompt(timeout, speechDuration)

void

Detect voicemail prompt on the call. Please note that this method is based on specific audio signal pattern which isn't always in place, so there is no 100% guarantee that it will detect voicemail in all situations.

Parameters
  • timeout: Number (optional)

    Optional before speech timeout in sec. 5 sec by default

  • speechDuration: Number (optional)

    Optional speech duration in sec. 2 sec by default

detectVoicemailTone(timeout, threshold)

void

Detect tone signal in the range 500 - 2000 Hz on the call

Parameters
  • timeout: Number (optional)

    Optional timeout in sec. 20 sec by default

  • threshold: Number (optional)

    Minimal detected tone duration. 100 ms by default

displayName()

String

Returns Display name for the call

Returns
  • String

handleMicStatus(handle)

void

Handle microphone status on the call

Parameters
  • handle: Boolean

    Enable/disable microphone status analysis

handleTones(doHandle)

void

Change DTMF processing mode

Parameters
  • doHandle: Boolean

    If true, each received signal causes ToneReceived event to be dispatched from this Call. Otherwise DTMF signals received from the call, are passed with audio and video data to other calls, that this call is joined to.

hangup(extraHeaders)

void

End the call

Parameters
  • extraHeaders: Object (optional)

    Optional custom parameters (SIP headers) that should be passed with hangup request. Parameter names must start with "X-" to be processed by application

id()

String

Returns call id

Returns
  • String

incoming()

boolean

Returns true if the call is incoming, false if it was originated from script

Returns
  • boolean

number()

String

Returns dialed number

Returns
  • String

playProgressTone(country)

void

Play country specific progress tone

Note that for this to work properly for call that is not yet connected, you need to invoke Call.startEarlyMedia before using this function
Example

Play Russian progress tone to the call

call.startEarlyMedia();
call.playProgressTone("RU");
Example

Play US progress tone to the call

call.startEarlyMedia();
call.playProgressTone("US");
Parameters
  • country: String (optional)

    2-digit country code. Currently supported values are US, RU

record(params)

void

Start recording call. Both incoming and outgoing streams are being recorded. Emits CallEvents.RecordStarted and CallEvents.RecordStopped events.

Parameters

reject(code, extraHeaders)

void

Reject incoming call

Parameters
  • code: Number (optional)

    SIP status code

  • extraHeaders: Object (optional)

    Optional custom parameters (SIP headers) that should be passed with answer message. Parameter names must start with "X-" to be processed by application

removeEventListener(callevent, handler)

void

Remove event handler for specific event generated by call in specific application state

Parameters
  • callevent: Function

    Event class (i.e. CallEvents.Connected)

  • handler: Function (optional)

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

ring(extraHeaders)

void

Send call progress tone to specific call

Parameters
  • extraHeaders: Object (optional)

    Optional custom parameters (SIP headers) that should be passed with the message. Parameter names must start with "X-" to be processed by application

say(text, language, ttsoptions)

void

Say some text to the call

If text length exceeds 1500 characters Call.PlaybackFinished event is fired with error description.
Parameters
  • text: String

    Message that will be played to the call

  • language: String (optional)

    Language and voice to be used. List of all supported languages is available here

  • ttsoptions: VoxEngine.TTSOptions (optional)

    Optional parameters for TTS

sendDigits(digits)

void

Send DTMF digits to the peer

Parameters
  • digits: String

    Any combination of 0-9, *, #, p (pause) symbols

sendInfo(mimeType, body, headers)

void

Send Info (SIP INFO) message inside the call

Parameters
  • mimeType: String

    MIME type of the message

  • body: String

    Message content

  • headers: Object (optional)

    Optional headers to be passed with the message

sendMediaTo(targetMediaUnit)

void

Start sending media (voice and video) from this call to media unit specified in targetMediaUnit. Each call can send media to any number of other calls, but can receive from just one. So if targetCall was already receiving media from another call, that link would break.

Parameters

sendMessage(text)

void

Send text message during the call

Parameters
  • text: String

    Message text

startEarlyMedia(extraHeaders)

void

Start playing early media to the call. Can be used to play voicemail prompt

Parameters
  • extraHeaders: Object (optional)

    Optional custom parameters (SIP headers) that should be passed with the message. Parameter names must start with "X-" to be processed by application

startPlayback(url, loop)

void

Play audio file to the call

Note that for this to work properly for call that is not yet connected, you need to invoke Call.startEarlyMedia before using this function
Parameters
  • url: String

    HTTP/HTTPS url of audio file. Supported formats are: mp3, ogg. Maximum file size if 2 MBytes

  • loop: Boolean (optional)

    If true, playback will be looped.

state()

String

Returns current state of the call

Returns
  • String

stopMediaTo(targetMediaUnit)

void

Stop sending media (voice and video) from this call to media unit specified in targetMediaUnit.

Parameters
  • targetMediaUnit: Call|Conference

    media unit that will not receive media from this call anymore.

stopPlayback()

void

Stop audio playback that was started before by calling startPlayback

toString()

String

Returns human-readable description of the call

Returns
  • String

vad()

Boolean

Returns VAD status

Returns
  • Boolean