Rate this page:

Call

Methods

addEventListener

Copy URL
addEventListener(event: 

CallEvents

,
callback:

Function

):

void

Adds a handler for the specified CallEvents event. Use only functions as handlers; anything except a function leads to the error and scenario termination when a handler is called

Parameters

  • Event class (i.e., 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:

VoxEngine.AnswerParameters

):

void

Answer an inbound 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 event). Example: {'X-header':'value'}

  • Optional

    Custom parameters for answering calls.

Returns

  • type:

    void

answerDirect

Copy URL
answerDirect(peerCall: 

Call

,
extraHeaders:

{[header: string]: string}

,
parameters:

VoxEngine.AnswerParameters

):

void

Answer inbound 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 (/docs/references/websdk/enums/callevents.html#connected) event). Example: {'X-header':'value'}

  • Optional

    Custom parameters for answering calls.

Returns

  • type:

    void

callerid

Copy URL
callerid(): 

string

Returns Caller ID of the calling user, that is displayed to the called user. Normally it is some phone number that can be used for callback. IMPORTANT: test numbers rented from Voximplant cannot 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

|

undefined

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:

    undefined

decline

Deprecated
Copy URL

Use Call.reject instead

See Available Roles
decline(code: 

number

,
extraHeaders:

{[header: string]: string}

):

void

Rejects an inbound 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

displayName

Copy URL
displayName(): 

string

Returns a name of the calling user, that is displayed to the called user. Normally it is 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 is 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 is triggered at each status' change.

Parameters

  • handle:

    boolean

    Enable/disable microphone status analysis. False by default.

Returns

  • type:

    void

handleTones

Copy URL
handleTones(doHandle: 

boolean

):

void

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

Parameters

  • doHandle:

    boolean

    Enable/disable DTMF analysis. 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 is active before hangup.
  2. CallEvents.Failed if it is an outbound call that is not connected previously.If there are no other active calls and/or ACD requests in a call session the AppEvents.Terminating and AppEvents.Terminated events are triggered in 60 seconds (see the session limits for details).

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 inbound, false if it is 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: 

string

):

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 inbound stream always replaces the previous one.

Parameters

  • country:

    string

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

Returns

  • type:

    void

record

Copy URL
record(params: 

CallRecordParameters

):

void

Start recording inbound and outbound audio for this call. This method triggers the CallEvents.RecordStarted event. The default quality is 8kHz / 32kbps; the format is mp3.

Parameters

Returns

  • type:

    void

reject

Copy URL
reject(code: 

number

,
extraHeaders:

{[header: string]: string}

):

void

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

Parameters

  • code:

    number

    SIP status code with the rejection reason. You can pass any standard SIP code starting with 3xx, 4xx, 5xx and 6xx as a reject reason.

  • 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

Removes a handler for the specified CallEvents event

Parameters

Returns

  • type:

    void

ring

Copy URL
ring(extraHeaders: 

{[header: string]: string}

):

void

Provides progress tones for the inbound 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 inbound 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

Warning
Copy URL

This method internally operates the Player class and its events. Use the VoxEngine.createTTSPlayer to get more flexibility

See Available Roles
say(text: 

string

,
sayOptions:

SayOptions

):

void

Say some text to the CallEvents.Connected call. If text length exceeds 1500 characters the PlayerEvents.PlaybackFinished event is 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 inbound stream always replaces the previous one.

Parameters

  • text:

    string

    Message that is 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 inbound stream always replaces the previous one.

Parameters

  • targetMediaUnit:

    VoxMediaUnit

    Media unit that receives media.

  • Optional

    Custom parameters for WebSocket interaction only.

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:

string

,
maxVideoBitrate:

number

,
audioLevelExtension:

false

|

true

,
conferenceCall:

false

|

true

):

void

Informs call endpoint that early media sends before accepting the call. It allows playing voicemail prompt or music during establishing the connection. It does not allow to listen to call endpoint. Note that unanswered call can be in "early media" state only for 60 seconds, see the 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:

    string

    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

  • audioLevelExtension:

    false

    Optional
  • conferenceCall:

    false

    Optional

    Boolean value that specifies whether the call is coming from a conference. False by default

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 inbound 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 does not receive media from this call anymore.

Returns

  • type:

    void

stopPlayback

Copy URL
stopPlayback(): 

void

Stop audio playback that is 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

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