Call
Methods
addEventListener
addEventListener(event: , 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:
Event class (i.e., CallEvents.Connected)
callback:
Function
Handler function. A single parameter is passed - object with event information
Returns
type:
void
answer
answer(extraHeaders: {[header: string]: string}
, parameters: ): 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}
OptionalOptional 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'}
parameters:
OptionalCustom parameters for answering calls.
Returns
type:
void
answerDirect
answerDirect(peerCall: , extraHeaders: {[header: string]: string}
, parameters: ): void
Answer inbound call in peer-to-peer mode. Use it only for connecting P2P legs.
Parameters
peerCall:
The other P2P leg.
extraHeaders:
{[header: string]: string}
OptionalOptional 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'}
parameters:
OptionalCustom parameters for answering calls.
Returns
type:
void
callerid
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
clientType(): string
Returns
type:
string
customData
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
OptionalCustom call data to set. Maximum size is 200 bytes.
Returns
type:
string
type:
undefined
decline
decline(code: number
, extraHeaders: {[header: string]: string}
): void
Rejects an inbound call
Parameters
code:
number
SIP status code
extraHeaders:
{[header: string]: string}
OptionalOptional 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
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
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
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
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
hangup(extraHeaders: {[header: string]: string}
): void
Start finishing a call. It triggers one of the following events:
- CallEvents.Disconnected if a call is active before hangup.
- 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}
OptionalOptional 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
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
incoming(): boolean
Returns true if the call is inbound, false if it is originated from script
Returns
type:
boolean
notifyBlindTransferFailed
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
notifyBlindTransferSuccess(): void
Sends a notification of a successful call transfer with the message "200 OK".
Returns
type:
void
number
number(): string
Returns a dialed number of inbound or outbound call.
Returns
type:
string
playProgressTone
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
record(params: ): 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
params:
Record parameters
Returns
type:
void
reject
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}
OptionalOptional 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
removeEventListener(event: , callback: Function
): void
Removes a handler for the specified CallEvents event
Parameters
event:
Event class (i.e., CallEvents.Connected)
callback:
Function
OptionalHandler function. If not specified, all event listeners are removed
Returns
type:
void
ring
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}
OptionalOptional 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
This method internally operates the Player class and its events. Use the VoxEngine.createTTSPlayer to get more flexibility
say(text: string
, 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:
Parameters for TTS: language, progressive playback, volume, rate, etc.
Returns
type:
void
sendDigits
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
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}
OptionalOptional 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
sendMediaTo(targetMediaUnit: , optional: ): 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:
Media unit that receives media.
optional:
OptionalCustom parameters for WebSocket interaction only.
Returns
type:
void
sendMessage
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
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}
OptionalOptional 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
OptionalInternal information about codecs from the AppEvents.CallAlerting event
maxVideoBitrate:
number
OptionalSet the maximum possible video bitrate for the end user device in kbps
audioLevelExtension:
false
OptionalconferenceCall:
false
OptionalBoolean value that specifies whether the call is coming from a conference. False by default
Returns
type:
void
startPlayback
startPlayback(url: string
, 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:
Playback parameters: loop, progressive playback, etc.
Returns
type:
void
state
state(): string
Returns current state of the call. Possible values are TERMINATED | CONNECTED | PROGRESSING | ALERTING
Returns
type:
string
stopMediaTo
stopMediaTo(targetMediaUnit: ): void
Stop sending media (voice and video) from this call to media unit specified in targetMediaUnit.
Parameters
targetMediaUnit:
Media unit that does not receive media from this call anymore.
Returns
type:
void
stopPlayback
stopPlayback(): void
Stop audio playback that is started before by calling the Call.startPlayback method.
Returns
type:
void
toString
toString(): string
Returns human-readable description of the call
Returns
type:
string
vad
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