Skip to main content

CallRecording

Represents a recording of a call.

Obtain instances of this class by starting a Recording with one of the following methods:

Example​

Record the audio of the call as soon as the other party answers the phone. We also print the ID of the recording and, when the call ends, the URL (which can be used to download the recording).

import { SignalWire, Voice } from "@signalwire/realtime-api";

const client = await SignalWire({ project: "ProjectID Here", token: "Token Here" })

const call = await client.voice.dialPhone({
from: "+YYYYYYYYYY",
to: "+XXXXXXXXXX",
});

await call.playTTS({ text: "This call will be recorded." });

// Start recording
await call.recordAudio({
direction: "both",
endSilenceTimeout: 0,
terminators: "",
listen: {
onStarted: async (recording) => {
console.log("Recording started", recording.state);
call.playTTS({
text: "This is a recording test."
});

// Wait 5 seconds
setTimeout(async () => {
// Stop recording
await recording.stop();
}, 5000);

},
onEnded: async (recording) => {
console.log("Recording ended", recording.state);
call.hangup();
}
}
}).onStarted();

Properties​

id​

The unique ID for this recording.

Syntax: CallRecording.id()

Returns: string

Methods​

pause​

â–¸ pause(): Promise<CallRecording>

Pauses the recording.

ParametersValue
behavior?skip: Does not record during the pause period
silence: Replaces the actual audio of the call with silence during the pause period.

Returns​

Promise<CallRecording>

A promise that resolves to the CallRecording when the recording is paused.

Example​

const recording = await call.recordingAudio({ direction: "both"});
...
await recording.pause();

resume​

â–¸ resume(): Promise<CallRecording>

Resumes the recording.

Returns​

Promise<CallRecording>

A promise that resolves to the CallRecording when the recording is resumed.

Example​

const recording = await call.recordingAudio({ direction: "both"});
...
await recording.resume();

stop​

â–¸ stop(): Promise<CallRecording>

Stops the recording.

Returns​

Promise<CallRecording>

A promise that resolves to the CallRecording when the recording is stopped.

Example​

const recording = await call.recordAudio({ direction: "both" });
...
await recording.stop();

Events​

onStarted​

â–¸ CallCollect.listen({ onStarted: Callback }})

Emitted when the recording starts. Your event handler will receive the instance of CallRecording.

Parameters​

NameTypeDescription
recordingCallRecordingThe instance of CallRecording that started.

onFailed​

â–¸ CallCollect.listen({ onFailed: Callback }})

Emitted when the recording fails to start. Your event handler will receive the instance of CallRecording.

Parameters​

NameTypeDescription
recordingCallRecordingThe instance of CallRecording that failed.

onEnded​

â–¸ CallCollect.listen({ onEnded: Callback }})

Emitted when the recording ends. Your event handler will receive the instance of CallRecording.

Parameters​

NameTypeDescription
recordingCallRecordingThe instance of CallRecording that ended.