Rate this page:

Call

Methods

addEventListener

Copy URL
addEventListener(event: 

CallEvents

,
callback:

Function

):

void

Add handler for specific event generated by call in specific application state. Use only functions as handlers; anything except a function leads to the error and scenario termination when a handler will be called.

Parameters

  • One of the CallEvents (e.g. CallEvents.Connected)

  • callback:

    Function

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

Returns

  • type:

    void

answer

Copy URL
answer(extraHeaders: 

{[header: string]: string}

,
parameters:

AnswerParameters

):

void

Answer incoming call. Use it only for connecting non-P2P legs. Remember that you can use the Call.startEarlyMedia method before answering a call.

Parameters

  • extraHeaders:

    {[header: string]: string}

    Optional

    Optional custom parameters (SIP headers) that should be passed with an answer 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 Connected (https://voximplant.com/docs/references/websdk/enums/callevents.html#connected) event). Example: {'X-header':'value'}

  • parameters:

    AnswerParameters

    Optional

    Custom parameters for answering calls.

Returns

  • type:

    void

answerDirect

Copy URL
answerDirect(peerCall: 

Call

,
extraHeaders:

{[header: string]: string}

,
parameters:

AnswerParameters

):

any

Answer incoming call in peer-to-peer mode. Use it only for connecting P2P legs.

Parameters

  • peerCall:

    Call

    The other P2P leg.

  • extraHeaders:

    {[header: string]: string}

    Optional

    Optional custom parameters (SIP headers) that should be passed with an answer 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 Connected (https://voximplant.com/docs/references/websdk/enums/callevents.html#connected) event). Example: {'X-header':'value'}

  • parameters:

    AnswerParameters

    Optional

    Custom parameters for answering calls.

Returns

  • type:

    any

callerid

Copy URL
callerid(): 

string

Returns Caller ID of the calling user, that is displayed to the called user. Normally it's some phone number that can be used for callback. IMPORTANT: test numbers rented from Voximplant can't be used as CallerID, the values can be only real numbers.

Returns

  • type:

    string

clientType

Copy URL
clientType(): 

string

Returns

  • type:

    string

customData

Copy URL
customData(cData: 

string

):

string

|

void

Set or get custom string associated with the particular call (e.g. Call object). Additionally, the customData value could be sent from WEB/iOS/Android SDKs and then it became the customData value in the Call object. Note that if you received some value from SDK, you could always replace it manually. SDKs can pass customData in two ways: 1) when SDK calls to the Voximplant cloud 2) when SDK answers to the call from the Voximplant cloud. See the syntax and details in the appropriate references: WEB SDK call() / WEB SDK answer() / iOS call:settings: / iOS answerWithSettings / Android call / Android answer()

Parameters

  • cData:

    string

    Optional

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

Returns

  • type:

    string

  • type:

    void

decline

Copy URL
decline(code: 

number

,
extraHeaders:

{[header: string]: string}

):

void

DEPRECATED - see the Call.reject method || Rejects an incoming call

Parameters

  • code:

    number

    SIP status code

  • extraHeaders:

    {[header: string]: string}

    Optional

    Optional custom parameters (SIP headers) that should be passed with an answer 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

  • type:

    void

detectVoicemailTone

Copy URL
detectVoicemailTone(timeout: 

number

,
threshold:

number

):

void

Enables or disables Voicemail tone detection. Can be used only for outgoing calls. Tone signal is in the range 500 - 2000 Hz on the call. Right after the method’s call VoxEngine will start to scan a media stream. The scanning will stop after the timeout. If Voicemail tone is detected (or is not detected for some time), the CallEvents.VoicemailToneDetected or CallEvents.VoicemailToneNotDetected event will be triggered for the call object.

Parameters

  • timeout:

    number

    Optional

    Optional timeout in sec, 20 sec by default.

  • threshold:

    number

    Optional

    Minimal detected tone duration, 100 ms by default.

Returns

  • type:

    void

displayName

Copy URL
displayName(): 

string

Returns a name of the calling user, that is displayed to the called user. Normally it's a human-readable version of Call.callerid , e.g. a person's name.

Returns

  • type:

    string

handleBlindTransfer

Copy URL
handleBlindTransfer(handle: 

boolean

):

void

Enables or disables blind transfers. When enabled, the CallEvents.BlindTransferRequested event will be triggered to request for the third call leg within an existing session and notify the transfer initiator of the result.

Parameters

  • handle:

    boolean

    Enable/disable blind transfers.

Returns

  • type:

    void

handleMicStatus

Copy URL
handleMicStatus(handle: 

boolean

):

void

Enables or disables detection of microphone status in the call. If detection is enabled, the CallEvents.MicStatusChange event will be triggered at each status' change.

Parameters

  • handle:

    boolean

    Enable/disable microphone status analysis. It's false by default.

Returns

  • type:

    void

handleTones

Copy URL
handleTones(doHandle: 

boolean

):

void

Change DTMF processing mode. If it's true, each received signal triggers the CallEvents.ToneReceived .

Parameters

  • doHandle:

    boolean

    Enable/disable DTMF analysis. It's false by default.

Returns

  • type:

    void

hangup

Copy URL
hangup(extraHeaders: 

{[header: string]: string}

):

void

Start finishing a call. It triggers one of the following events:

  1. CallEvents.Disconnected if a call was active before hangup.
  2. CallEvents.Failed if it's an outbound call that wasn't connected previously.If there are no other active calls and/or ACD requests in a call session the AppEvents.Terminating and AppEvents.Terminated events will be triggered in 60 seconds (see the details in VoxEngine session limits).

Parameters

  • extraHeaders:

    {[header: string]: string}

    Optional

    Optional custom parameters (SIP headers) that should be passed with a hangup request. 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

  • type:

    void

id

Copy URL
id(): 

string

Returns call id. Each call in JavaScript session has its own unique id which is used to describe every action in the call logs.

Returns

  • type:

    string

incoming

Copy URL
incoming(): 

boolean

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

Returns

  • type:

    boolean

notifyBlindTransferFailed

Copy URL
notifyBlindTransferFailed(code: 

number

,
reason:

string

):

void

Sends a notification of a failed call transfer with an error code and reason.

Parameters

  • code:

    number

    Error code.

  • reason:

    string

    Reason why the blind transfer is failed.

Returns

  • type:

    void

notifyBlindTransferSuccess

Copy URL
notifyBlindTransferSuccess(): 

void

Sends a notification of a successful call transfer with the message "200 OK".

Returns

  • type:

    void

number

Copy URL
number(): 

string

Returns a dialed number of inbound or outbound call.

Returns

  • type:

    string

playProgressTone

Copy URL
playProgressTone(country: 

any

):

void

Provides country-specific progress tones. The method sends a command to the Voximplant cloud to start playing progress tones in the call. So the progress tones totally depend on the Voximplant cloud. Note that in order to work properly in a call that is not connected yet, you need to call the Call.startEarlyMedia method before using this function. IMPORTANT: each call object can send media to any number of other calls (media units), but can receive only one audio stream. A new incoming stream always replaces the previous one.

Parameters

  • country:

    any

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

Returns

  • type:

    void

record

Copy URL
record(params: 

RecorderParameters

):

void

Start recording incoming and outgoing audio for this call. This method triggers the CallEvents.RecordStarted event. The default quality is 8kHz / 32kbps; the format is mp3. See this article for details.

Parameters

Returns

  • type:

    void

reject

Copy URL
reject(code: 

number

,
extraHeaders:

{[header: string]: string}

):

void

Reject an incoming call. Firstly it triggers the CallEvents.Disconnected event immediately. The AppEvents.Terminating and AppEvents.Terminated events will be triggered in 60 seconds.

Parameters

  • code:

    number

    SIP status code

  • extraHeaders:

    {[header: string]: string}

    Optional

    Optional custom parameters (SIP headers) that should be passed with an answer 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

  • type:

    void

removeEventListener

Copy URL
removeEventListener(event: 

CallEvents

,
callback:

Function

):

void

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

Parameters

  • One of the CallEvents (e.g. CallEvents.Connected)

  • callback:

    Function

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

Returns

  • type:

    void

ring

Copy URL
ring(extraHeaders: 

{[header: string]: string}

):

void

Provides progress tones for the incoming call. The method sends a low-level command to the endpoint device to start playing progress tones in the call. So the progress tones depend on endpoint device's behavior rather than the Voximplant cloud. IMPORTANT: each call object can send media to any number of other calls (media units), but can receive only one audio stream. A new incoming stream always replaces the previous one.

Parameters

  • extraHeaders:

    {[header: string]: string}

    Optional

    Optional custom parameters (SIP headers) that should be passed with the 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

  • type:

    void

say

Copy URL
say(text: 

string

,
sayOptions:

sayOptions

):

void

Say some text to the CallEvents.Connected call. If text length exceeds 1500 characters the PlayerEvents.PlaybackFinished event will be triggered with error description. IMPORTANT: each call object can send media to any number of other calls (media units), but can receive only one audio stream. A new incoming stream always replaces the previous one.

Parameters

  • text:

    string

    Message that will be played to the call. To put an accent in specified syllabus, use tag <say-as stress='1'> </say-as>.

  • sayOptions:

    sayOptions

    Parameters for TTS: language, progressive playback, volume, rate, etc.

Returns

  • type:

    void

sendDigits

Copy URL
sendDigits(digits: 

string

):

void

Send DTMF digits to the remote peer.

Parameters

  • digits:

    string

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

Returns

  • type:

    void

sendInfo

Copy URL
sendInfo(mimeType: 

string

,
body:

string

,
headers:

{[header: string]: string}

):

void

Send Info (SIP INFO) message inside the call

Parameters

  • mimeType:

    string

    MIME type of the message.

  • body:

    string

    Message content. Maximum size is 8192 bytes according to the limits.

  • headers:

    {[header: string]: string}

    Optional

    Optional headers to be passed with the 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

  • type:

    void

sendMediaTo

Copy URL
sendMediaTo(targetMediaUnit: 

VoxMediaUnit

,
optional:

sendMediaOptions

):

void

Start sending media (voice and video) from this call to media unit specified in targetMediaUnit. The target call has to be CallEvents.Connected earlier. IMPORTANT: each call object can send media to any number of other calls (media units), but can receive only one audio stream. A new incoming stream always replaces the previous one.

Parameters

Returns

  • type:

    void

sendMessage

Copy URL
sendMessage(text: 

string

):

void

Send text message during the call. See the similar methods in the Android SDKs.

Parameters

  • text:

    string

    Message text. Maximum size is 8192 bytes according to the limits.

Returns

  • type:

    void

startEarlyMedia

Copy URL
startEarlyMedia(extraHeaders: 

{[header: string]: string}

,
scheme:

{[id: string]: any}

,
maxVideoBitrate:

number

):

void

Informs call endpoint that early media will be sent before accepting the call. It allows playing voicemail prompt or music during establishing the connection. It doesn't allow to listen to call endpoint. Note that unanswered call can be in "early media" state only for 60 seconds, see the VoxEngine session limits for details.

Parameters

  • extraHeaders:

    {[header: string]: string}

    Optional

    Optional custom parameters (SIP headers) that should be passed with the 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'}

  • scheme:

    {[id: string]: any}

    Optional

    Internal information about codecs from the AppEvents.CallAlerting event.

  • maxVideoBitrate:

    number

    Optional

    Set the maximum possible video bitrate for the end user device in kbps.

Returns

  • type:

    void

startPlayback

Copy URL
startPlayback(url: 

string

,
startPlaybackOptions:

startPlaybackOptions

):

void

Starts to play audio file to the answered call. You can stop playing manually by using the Call.stopPlayback method. Media streams can later be attached using the Call.sendMediaTo method etc. IMPORTANT: each call object can send media to any number of other calls (media units), but can receive only one audio stream. A new incoming stream always replaces the previous one.

Parameters

  • url:

    string

    HTTP/HTTPS url of audio file. The file is cached after the first playing. Supported formats are: mp3, ogg & flac (mp3, speex, vorbis and flac codecs respectively). Maximum file size is 10 Mb.

  • startPlaybackOptions:

    startPlaybackOptions

    Playback parameters: loop, progressive playback, etc.

Returns

  • type:

    void

state

Copy URL
state(): 

string

Returns current state of the call. Possible values are: TERMINATED | CONNECTED | PROGRESSING | ALERTING

Returns

  • type:

    string

stopMediaTo

Copy URL
stopMediaTo(targetMediaUnit: 

VoxMediaUnit

):

void

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

Parameters

  • targetMediaUnit:

    VoxMediaUnit

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

Returns

  • type:

    void

stopPlayback

Copy URL
stopPlayback(): 

void

Stop audio playback that was started before by calling the Call.startPlayback method.

Returns

  • type:

    void

toString

Copy URL
toString(): 

string

Returns human-readable description of the call

Returns

  • type:

    string

transferTo

Copy URL
transferTo(to: 

string

,
options:

callSIPParameters

):

void

Transfer a SIP call to a 3rd party provider which supports the REFER command. If the transfer is successful, Voximplant disconnects from handling this call and the TransferComplete event is triggered. Otherwise, the TransferFailed event is triggered.

Parameters

  • to:

    string

    SIP(S) URI to make a call to. Example of an external call: sip:alice@example.org. Examples with the usage of TLS: sips:alice@example.org:5061 ; alice@example.org:5061;transport=tls. The format for calls to another user of the same Voximplant application: user-of-the-application@application-name.account-name.voximplant.com

  • Object with callSIP parameters.

Returns

  • type:

    void

vad

Copy URL
vad(): 

boolean

Returns VAD (Voice Activity Detection) status. The including of the ASR also activates VAD so in that case vad() returns true.

Returns

  • type:

    boolean