Call
The Call object represents one audio or video call leg in a VoxEngine scenario. It is typically received from call events or returned by dialing APIs, then methods such as answer, sendMediaTo, record, and addEventListener are called on that call instance. Related event names, event payloads, and parameter objects are documented on this page because they describe the same call lifecycle.
Related guides
Understand call legs, sessions, and media units in VoxEngine.
Start from the standard inbound call pattern.
Start from the standard outbound call pattern.
Route calls through SIP trunks, SIP users, and SIP registrations.
Contents
- Methods: answer, reject, bridge media, record, play audio, and control call state.
- CallEvents: event names and callback payload fields for the call lifecycle.
- Parameter types: option objects used by Call methods.
Methods
addEventListener
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
Returns
answer
Answers the incoming call. Use it only for non-P2P call legs connection. Remember that you can use the Call.startEarlyMedia method before answering a call.
Parameters
Returns
answerDirect
Answer the incoming call in the peer-to-peer mode. Use it only for P2P call legs connection.
Parameters
Returns
callerid
Returns the callerID of the caller, which is displayed to the callee. Normally it is some phone number that can be used for callback. IMPORTANT: test numbers rented from Voximplant cannot be used as CallerIDs, the values can be only real numbers.
Parameters
This method does not accept parameters.
Returns
clientType
Returns a type of the client. The possible values are: ‘pstn’, ‘sip’, ‘user’, ‘wab’.
Parameters
This method does not accept parameters.
Returns
customData
Sets or gets a custom string associated with the particular call (the Call object). The customData value could be sent from WEB/iOS/Android SDKs, and then it becomes the customData value in the Call instance. Note that if you receive a value from an SDK, you can always replace it manually. SDKs can pass customData in two ways:
- when SDK calls the Voximplant cloud
- when SDK answers the call from the Voximplant cloud. See the syntax and details in the corresponding references: WEB SDK call() / WEB SDK answer() / iOS call:settings: / iOS answerWithSettings / Android call() / Android answer()
Parameters
Returns
decline
Deprecated
Use Call.reject instead
Rejects the incoming call.
Parameters
Returns
disableBeepDetection
Disables beep detection in a call.
Parameters
This method does not accept parameters.
Returns
displayName
Returns the name of the caller, which is displayed to the callee. Normally it is a human-readable version of Call.callerid, e.g. a person’s name.
Parameters
This method does not accept parameters.
Returns
enableBeepDetection
Enables beep detection in a call. The beep detection is used to detect beeps in the call audio stream.
Parameters
Returns
handleBlindTransfer
Whether to enable 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
Returns
handleMicStatus
Whether to enable detection of microphone status in the call. If detection is enabled, the CallEvents.MicStatusChange event is triggered at each status’ change.
Parameters
Returns
handleTones
Changes DTMF processing mode (in-band DTMF, RFC 2833 DTMF and DTMF over SIP INFO) telephony signals. If true, each received DTMF signal triggers the CallEvents.ToneReceived and removes from audio stream.
Parameters
Returns
hangup
Attempts finishing the current call. Triggers one of the following events:
CallEvents.Disconnectedif the call is active before hangup.CallEvents.Failedif it is an outgoing call that is not connected previously. If there are no other active calls and/or SmartQueue requests in the call session, theAppEvents.TerminatingandAppEvents.Terminatedevents are triggered in 60 seconds (see the session limits for details).
Parameters
Returns
id
Returns the call’s id. Each call in a JavaScript session has its own unique id.
Parameters
This method does not accept parameters.
Returns
incoming
Whether the call is incoming.
Parameters
This method does not accept parameters.
Returns
monitorMediaStatistics
Enables the retrieval of multimedia statistics during a call. When enabled, the CallEvents.MediaStatisticsReceived event is triggered and retrieves multimedia statistics during a call.
Parameters
Returns
notifyBlindTransferFailed
Sends a notification about a failed call transfer with an error code and reason.
Parameters
Returns
notifyBlindTransferSuccess
Sends a notification of a successful call transfer with the 200 OK message.
Parameters
This method does not accept parameters.
Returns
number
Returns a dialed number of the incoming or outgoing call.
Parameters
This method does not accept parameters.
Returns
playProgressTone
Provides country-specific dial tones. The method sends a command to the Voximplant cloud to start playing dial tones in the call. The dial tones fully 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
Returns
record
Starts recording the incoming and outgoing audio for this call.
This method triggers the CallEvents.RecordStarted event.
The default quality is 8kHz / 32kbps; the format is mp3.
Parameters
Returns
reject
Rejects the incoming call. First it triggers the CallEvents.Disconnected event immediately. The AppEvents.Terminating and AppEvents.Terminated events are triggered in 60 seconds.
Parameters
Returns
removeEventListener
Removes a handler for the specified CallEvents event.
Parameters
Returns
ring
Plays dial tones for the incoming call. The method sends a low-level command to the endpoint device to start playing dial tones for the call. So the dial tones depend on endpoint device’s behavior rather than on 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
Returns
say
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 incoming stream always replaces the previous one.
Parameters
Returns
sendDigits
Sends DTMF digits to the remote peer.
Parameters
Returns
sendInfo
Sends info (SIP INFO) message to the call.
Parameters
Returns
sendMediaTo
Starts sending media (voice and video) from the call to the media unit. The target call has to be CallEvents.Connected earlier. IMPORTANT: each call object can send media to any number of the media units, but can receive only one audio stream. A new incoming stream always replaces the previous one.
Parameters
Returns
sendMessage
Sends a text message to the call.
Parameters
Returns
startEarlyMedia
Informs the call endpoint that early media is sent before accepting the call. It allows playing voicemail prompt or music before 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
Returns
startPlayback
Starts to play an audio file to the answered call. You can stop playback manually via the Call.stopPlayback method. You can attach media streams later via 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
Returns
state
Returns the current state of the call. Possible values are: TERMINATED | CONNECTED | PROGRESSING | ALERTING.
Parameters
This method does not accept parameters.
Returns
stopMediaTo
Stops sending media (voice and video) from the call to media unit.
Parameters
Returns
stopPlayback
Stops audio playback started before via the Call.startPlayback method.
Parameters
This method does not accept parameters.
Returns
toString
Returns the human-readable description of the call’s status.
Parameters
This method does not accept parameters.
Returns
transferTo
Transfers 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 CallEvents.TransferComplete event is triggered. Otherwise, the CallEvents.TransferFailed event is triggered.
Parameters
Returns
vad
Returns VAD (Voice Activity Detection) status. The including of the ASR also activates VAD so in that case vad() returns true.
Parameters
This method does not accept parameters.
Returns
CallEvents
Subscribe with Call.addEventListener. Each event callback receives an object with the fields documented below.
AudioStarted
Triggers after remote peer answered the call or set the call into the Call.startEarlyMedia state. Note that event is not triggered in P2P mode.
This event occurs after receiving the 183 Session Progress SIP message regardless of receiving actual media packets.
Event constant: CallEvents.AudioStarted
Payload
AudioIdentificationStarted
Triggers when voicemail detection system connects to the VMD/AMD server and starts detecting voicemail.
Event constant: CallEvents.AudioIdentificationStarted
Payload
AudioIdentificationResult
Triggers when voicemail detection ends detecting voicemail and the audio identification result is received.
Event constant: CallEvents.AudioIdentificationResult
Payload
AudioIdentificationStopped
Triggers when voicemail detection stops detecting voicemail.
Event constant: CallEvents.AudioIdentificationStopped
Payload
AudioIdentificationError
Triggers when voicemail detection occurs an error.
Event constant: CallEvents.AudioIdentificationError
Payload
BlindTransferRequested
Triggered when blind transfers are enabled by Call.handleBlindTransfer.
Event constant: CallEvents.BlindTransferRequested
Payload
Connected
Triggers after an incoming/outgoing call is connected. For incoming call, it happens after the Call.answer is called. For outgoing call, it happens when a remote peer answers the call.
Event constant: CallEvents.Connected
Payload
Forwarding
Triggers on an incoming/outgoing call forwarding.
Event constant: CallEvents.Forwarding
Payload
Disconnected
Triggered when a call is terminated.
Most frequent status codes (returned when a call is terminated before being answered):
CodeDescription
408Call is not answered within 60 seconds 603Call is rejected 486Destination number is busy 487Request terminated
You can find the complete list of rfc3261 response codes on Wikipedia.
Note that this event does not mean the end of the JavaScript session.
The session without calls and/or ACD requests are automatically terminated after some time (see the session limits for details).
It is a good idea to explicitly terminate the session with VoxEngine.terminate(/docs/references/voxengine/voxengine/terminate) after it is no longer needed.
Event constant: CallEvents.Disconnected
Payload
Failed
Triggered when an outgoing call is terminated before connection. Most frequent status codes:
CodeDescription
486Destination number is busy 487Request terminated 404Invalid number 480Destination number is unavailable 402Insufficient funds 603Call was rejected 408Call was not answered within 60 seconds
Event constant: CallEvents.Failed
Payload
InfoReceived
Triggered when an INFO message is received.
Event constant: CallEvents.InfoReceived
Payload
MessageReceived
Triggered when a text message is received.
Event constant: CallEvents.MessageReceived
Payload
MicStatusChange
Triggers each time when microphone status changes. There is the method for enabling status analyzing - Call.handleMicStatus.
Event constant: CallEvents.MicStatusChange
Payload
OffHold
Triggered when a call is taken off hold.
Event constant: CallEvents.OffHold
Payload
OnHold
Triggered when a call is put on hold.
Event constant: CallEvents.OnHold
Payload
PlaybackFinished
Triggered when the audio/voice playback is completed.
Note that the Call.stopPlayback method finishes any media**, so the CallEvents.PlaybackFinished event is not triggered. The playback may be started by the Call.say or Call.startPlayback methods.
Event constant: CallEvents.PlaybackFinished
Payload
PlaybackReady
Triggers by the Call.startPlayback and Call.say methods when:
- the audio file download to the Voximplant cache is finished;
- the audio file is found in the cache (i.e., it is in the cache before).
Event constant: CallEvents.PlaybackReady
Payload
PlaybackStarted
Triggers by the Call.startPlayback and Call.say methods when audio/voice playback is started.
Event constant: CallEvents.PlaybackStarted
Payload
PushSent
Triggered when a push notification is sent.
Event constant: CallEvents.PushSent
Payload
ReInviteAccepted
Triggered when the Voximplant cloud receives the ReInviteAccepted message. This message means that a call received video from the other participant.
Event constant: CallEvents.ReInviteAccepted
Payload
ReInviteReceived
Triggered when the Voximplant cloud receives the ReInviteReceived message. This message means that a caller:
- started sending video;
- started/stopped screensharing;
- put a call on hold / took a call off hold.
Event constant: CallEvents.ReInviteReceived
Payload
ReInviteRejected
Triggered when the Voximplant cloud receives the ReInviteRejected message. This message means that a call does not receive video from the other participant.
Event constant: CallEvents.ReInviteRejected
Payload
RecordStarted
Triggered when call recording is started. The recording may be started by the Call.record method.
Event constant: CallEvents.RecordStarted
Payload
RecordStopped
Triggered when call recording is stopped. This happens after the CallEvents.Disconnected event is triggered.
Event constant: CallEvents.RecordStopped
Payload
RecordError
Triggers in case of errors during the recording process.
Event constant: CallEvents.RecordError
Payload
Ringing
Triggers after outgoing call receives progress signal from a remote peer.
Event constant: CallEvents.Ringing
Payload
StateChanged
Triggered when a call status is changed.
Event constant: CallEvents.StateChanged
Payload
Statistics
Triggered when call statistics change.
Event constant: CallEvents.Statistics
Payload
ToneDetected
Triggered when a call dial tone is detected (either dial tone or busy tone). There is the deprecated method for enabling the tone detection - ‘Call.detectProgressTone’. Note that:
- triggers only if the
CallEvents.Connectedevent is triggered; - the event is only triggered once in a call session.
Event constant: CallEvents.ToneDetected
Payload
ToneReceived
Triggered when a DTMF signal is received. Note that by default DTMF signals do not trigger this event, this behavior needs to be set explicitly via the Call.handleTones method.
Event constant: CallEvents.ToneReceived
Payload
TransferComplete
Triggered when a call transfer is complete.
Event constant: CallEvents.TransferComplete
Payload
TransferFailed
Triggered when a call transfer is failed.
Event constant: CallEvents.TransferFailed
Payload
VideoTrackCreated
Triggers after the video track is created. This could happen only if the Call.record method with {video: true} parameters is called.
Event constant: CallEvents.VideoTrackCreated
Payload
FirstAudioPacketReceived
Triggers after the first audio packet is received.
Event constant: CallEvents.FirstAudioPacketReceived
Payload
FirstVideoPacketReceived
Triggers after the first video packet is received.
Event constant: CallEvents.FirstVideoPacketReceived
Payload
RtpStopped
Triggers within 7 seconds after the RTP/RTCP has stopped. Applies to all types of calls (users, SIP, and PSTN).
Event constant: CallEvents.RtpStopped
Payload
RtpResumed
Triggers after the RTP resumed.
Event constant: CallEvents.RtpResumed
Payload
BeepDetectionComplete
Triggers after the beep detection is complete. The beep detection may be started by the Call.enableBeepDetection method.
Event constant: CallEvents.BeepDetectionComplete
Payload
BeepDetectionError
Error during beep detection.
Event constant: CallEvents.BeepDetectionError
Payload
AudioQualityDetected
MediaStatisticsReceived
Triggers after media statistics has been recieved. To enable, call the Call.monitorMediaStatistics method.
Event constant: CallEvents.MediaStatisticsReceived
Payload
Parameter types
CallAnswerParameters
The parameters can be passed as arguments to the Call.answer method.
CallEnableBeepDetectionParameters
Parameters for the Call.enableBeepDetection method.
CallRecordParameters
The parameters can be passed as arguments to the Call.record method.
CallSayParameters
The parameters can be passed as arguments to the Call.say method.
SendMediaParameters
Custom parameters for WebSocket interaction. Can be passed as arguments to the VoxMediaUnit sendMediaTo method.
StartPlaybackParameters
The parameters can be passed as arguments to the Call.startPlayback method.
TransferToParameters
The parameters can be passed as arguments to the Call.transferTo method.
MonitorMediaStatisticsParameters
The parameters can be passed as arguments to the Call.monitorMediaStatistics method.