The direction of the call.
Can be either inbound or outbound.
The call identifier.
The previous state of the call.
See Call.state for all possible values.
The state of the call.
| Value | Description |
|---|---|
new |
New call has been created in the client. |
trying |
It's attempting to call someone. |
requesting |
The outbound call is being sent to the server. |
recovering |
The previous call is recovering after the page refreshes. If the user refreshes the page during a call, it will automatically join the latest call. |
ringing |
Someone is attempting to call you. |
answering |
You are attempting to answer this inbound call. |
early |
It receives the media before the call has been answered. |
active |
Call has become active. |
held |
Call has been held. |
hangup |
Call has ended. |
destroy |
Call has been destroyed. |
purge |
Call has been purged. |
Gets the local stream of the call. This can be used in a video/audio element to play the local media. See MediaStream.
const stream = call.localStream;
document.querySelector('audio').srcObject = stream;
Gets the remote stream of the call. This can be used in a video/audio element to play the remote media. See MediaStream.
const stream = call.remoteStream;
document.querySelector('audio').srcObject = stream;
Gets Telnyx call IDs, if using Telnyx Call Control services. You can use these IDs to identify specific calls in your application code.
const { telnyxCallControlId, telnyxSessionId, telnyxLegId } = call.telnyxIDs;
Changes the audio input device (i.e. microphone) used for the call.
The target audio input device ID
Promise that resolves if the audio input device has been updated
Using async/await:
await call.setAudioInDevice('abc123')
Using ES6 Promises:
call.setAudioInDevice('abc123').then(() => {
// Do something using new audio input device
});
Usage with .getAudioInDevices:
let result = await client.getAudioInDevices();
if (result.length) {
call.setAudioInDevice(result[1].deviceId);
}
Changes the audio output device (i.e. speaker) used for the call.
The target audio output device ID
Promise that returns a boolean
Using async/await:
await call.setAudioOutDevice('abc123')
Using ES6 Promises:
call.setAudioOutDevice('abc123').then(() => {
// Do something using new audio output device
});
Usage with .getAudioOutDevices:
let result = await client.getAudioOutDevices();
if (result.length) {
await call.setAudioOutDevice(result[1].deviceId);
}
Changes the video device (i.e. webcam) used for the call.
the target video device ID
Promise that resolves if the video device has been updated
Using async/await:
await call.setVideoDevice('abc123')
Using ES6 Promises:
call.setVideoDevice('abc123').then(() => {
// Do something using new video device
});
Usage with .getVideoDevices:
let result = await client.getVideoDevices();
if (result.length) {
await call.setVideoDevice(result[1].deviceId);
}
Removes hold from the call.
Promise that resolves or rejects based on server response
Using async/await:
await call.unhold()
console.log(call.state) // => 'active'
Using ES6 Promises:
call.unhold().then(() => {
console.log(call.state) // => 'active'
});
A
Callis the representation of an audio or video call between two browsers, SIP clients or phone numbers. Thecallobject is created whenever a new call is initiated, either by you or the remote caller. You can access and act upon calls initiated by a remote caller in atelnyx.notificationevent handler.Examples
To create a new call, i.e. dial:
To answer an incoming call:
Both the outgoing and incoming call has methods that can be hooked up to your UI.