Skip to main content

CallRecording

Represents a recording of a call. You can obtain instances of this class by starting a Recording with one of the following methods:

Example

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

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

const client = new Voice.Client({
project: "<project-id>",
token: "<api-token>",
topics: ["office"],
});

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

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

// Print out the URL of the recording, as soon as the recording ends.
call.on("recording.ended", (recording) => {
console.log("Recording URL:", recording.url);
});

// Start recording
const recording = await call.recordAudio({
direction: "both",
endSilenceTimeout: 0,
terminators: "",
});
console.log("Recording id:", recording.id);

Properties

id

The unique id for this recording.

Syntax: CallRecording.id()

Returns: string

Methods

pause

pause(): Promise<CallRecording> - See CallRecording for more details.

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> - See CallRecording for more details.

Example

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

resume

resume(): Promise<CallRecording> - See CallRecording for more details.

Resumes the recording.

Returns

Promise<CallRecording> - See CallRecording for more details.

Example

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

stop

stop(): Promise<CallRecording> - See CallRecording for more details.

Stops the recording.

Returns

Promise<CallRecording> - See CallRecording for more details.

Example

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