Skip to contentSkip to navigationSkip to topbar
On this page

How to record a single side of a call


By default Twilio's voice recordings capture all audio from a call in a single mono-channel file. To separate audio tracks in two channels, you can use recordingChannel=dual

Single Party Call Recordings is a feature that provides flexibility over which parties should be recorded during a call and it allows you to programmatically record only one side of the call.


How it works

how-it-works page anchor

RecordingTrack is an optional parameter that can be used to select whether the inbound, outbound or both audio tracks of the call should be recorded. The inbound track represents the audio received by Twilio, and the outbound track represents the audio that Twilio generates on the call.

For example, if the caller is interacting with an IVR, the inbound track contains the caller's voice and the outbound track contains the audio generated via either <Say> or <Play>. Alternatively, if the caller is connected to agent via <Dial>, then the outbound track will contain the audio spoken by agent.

(warning)

Warning

When inbound or outbound audio track is recorded, the resulting recording file will always be mono-channel. When audio is recorded using both, you can choose either separate channel (dual) or mixed (mono).

This table illustrates the expected outcome when using recordingTrack and attributes together to request a recording:

RecordingTrackRecordingChannelOutcome
--Records the inbound and the outbound audio of the call mixed in a single channel of the recording file.
-monoRecords the inbound and the outbound audio of the call mixed in a single channel of the recording file.
-dualRecords the inbound and the outbound audio of the call in two separate channels of the recording file.
inbound-Records the inbound audio of the call in a single channel of the recording file. The inbound track is the audio that is received by Twilio from the call.
outbound-Records the outbound audio of the call in a single channel of the recording file. The outbound track is the audio that is generated by Twilio.
both-Records the inbound and the outbound audio of the call mixed in a single channel of the recording file.
inboundmonoRecords the inbound audio of the call in a single channel of the recording file. The inbound track is the audio that is received by Twilio from the call.
inbounddual (→ mono)Records the inbound audio of the call in a single channel of the recording file. The inbound track is the audio that is received by Twilio from the call. Note: if you set "RecordingChannel=dual", this will be ignored and automatically set to mono.
outboundmonoRecords the outbound audio of the call in a single channel of the recording file. The outbound track is the audio that is generated by Twilio.
outbounddual (→ mono)Records the outbound audio of the call in a single channel of the recording file. The outbound track is the audio that is generated by Twilio. Note: if you set "RecordingChannel=dual", this will be ignored and automatically set to mono.
bothmonoRecords the inbound and the outbound audio of the call mixed in a single channel of the recording file.
bothdualRecords the inbound and the outbound audio of the call in two separate channels of the recording file

How to configure Single Party Call Recording

how-to-configure-single-party-call-recording page anchor

You can enable single party recording for any given call using the following Twilio's Programmable Voice APIs:

(information)

Info

This feature is not yet available in TwiML <Record> or <Conference>. SIP Trunking calls also do not currently support this functionality.

Set RecordingTrack on a new outbound CallLink to code sample: Set RecordingTrack on a new outbound Call
1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function createCall() {
11
const call = await client.calls.create({
12
from: "+14155552344",
13
record: true,
14
recordingTrack: "outbound",
15
to: "+14155552345",
16
url: "https://www.example.com",
17
});
18
19
console.log(call.sid);
20
}
21
22
createCall();

Output

1
{
2
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
3
"annotation": null,
4
"answered_by": null,
5
"api_version": "2010-04-01",
6
"caller_name": null,
7
"date_created": "Tue, 31 Aug 2010 20:36:28 +0000",
8
"date_updated": "Tue, 31 Aug 2010 20:36:44 +0000",
9
"direction": "inbound",
10
"duration": "15",
11
"end_time": "Tue, 31 Aug 2010 20:36:44 +0000",
12
"forwarded_from": "+141586753093",
13
"from": "+14155552344",
14
"from_formatted": "(415) 867-5308",
15
"group_sid": null,
16
"parent_call_sid": null,
17
"phone_number_sid": "PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
18
"price": "-0.03000",
19
"price_unit": "USD",
20
"sid": "CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
21
"start_time": "Tue, 31 Aug 2010 20:36:29 +0000",
22
"status": "completed",
23
"subresource_uris": {
24
"notifications": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications.json",
25
"recordings": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings.json",
26
"payments": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Payments.json",
27
"events": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Events.json",
28
"siprec": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Siprec.json",
29
"streams": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Streams.json",
30
"transcriptions": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Transcriptions.json",
31
"user_defined_message_subscriptions": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/UserDefinedMessageSubscriptions.json",
32
"user_defined_messages": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/UserDefinedMessages.json"
33
},
34
"to": "+14155552345",
35
"to_formatted": "(415) 867-5309",
36
"trunk_sid": null,
37
"uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json",
38
"queue_time": "1000"
39
}
(warning)

Warning

The default value of the record attribute is do-not-record. Make sure you set this to true as it will not be automatically enabled regardless of RecordingTrack property.

1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function createCallRecording() {
11
const recording = await client
12
.calls("CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
13
.recordings.create({ recordingTrack: "inbound" });
14
15
console.log(recording.accountSid);
16
}
17
18
createCallRecording();

Output

1
{
2
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
3
"api_version": "2010-04-01",
4
"call_sid": "CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
5
"conference_sid": null,
6
"channels": 2,
7
"date_created": "Fri, 14 Oct 2016 21:56:34 +0000",
8
"date_updated": "Fri, 14 Oct 2016 21:56:34 +0000",
9
"start_time": "Fri, 14 Oct 2016 21:56:34 +0000",
10
"price": null,
11
"price_unit": null,
12
"duration": null,
13
"sid": "REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
14
"source": "StartCallRecordingAPI",
15
"status": "in-progress",
16
"error_code": null,
17
"encryption_details": null,
18
"track": "both",
19
"uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings/REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json"
20
}
Configure recording party when adding a new participant to a conferenceLink to code sample: Configure recording party when adding a new participant to a conference
1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function createParticipant() {
11
const participant = await client
12
.conferences("ConferenceSid")
13
.participants.create({
14
from: "+14155552344",
15
record: true,
16
recordingTrack: "inbound",
17
to: "+14155552345",
18
});
19
20
console.log(participant.accountSid);
21
}
22
23
createParticipant();

Output

1
{
2
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
3
"call_sid": "CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
4
"label": "customer",
5
"conference_sid": "ConferenceSid",
6
"date_created": "Fri, 18 Feb 2011 21:07:19 +0000",
7
"date_updated": "Fri, 18 Feb 2011 21:07:19 +0000",
8
"end_conference_on_exit": false,
9
"muted": false,
10
"hold": false,
11
"status": "queued",
12
"start_conference_on_enter": true,
13
"coaching": false,
14
"call_sid_to_coach": null,
15
"queue_time": "1000",
16
"uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json"
17
}

Configure recording party using <Dial>

configure-recording-party-using-dial page anchor

Use <Dial> verb to dial a new participant from an active ongoing call and record the call specifying what audio should be recorded using recordingTrack parameter. The following example illustrates how to record the inbound audio:

(warning)

Warning

The default value of the record attribute is do-not-record. Make sure you set this to true as it will not be automatically enabled regardless of RecordingTrack property.

1
const VoiceResponse = require('twilio').twiml.VoiceResponse;
2
3
const response = new VoiceResponse();
4
const dial = response.dial({
5
record: 'record-from-answer',
6
recordingTrack: 'inbound',
7
recordingStatusCallback: 'https://www.myexample.com/recording-handler'
8
});
9
dial.number('+15551239876');
10
11
console.log(response.toString());

Output

1
<Response>
2
<Dial record="record-from-answer"
3
recordingTrack="inbound"
4
recordingStatusCallback="https://www.myexample.com/recording-handler">
5
<Number>+15551239876</Number>
6
</Dial>
7
</Response>

How to determine which track has been recorded

how-to-determine-which-track-has-been-recorded page anchor

The request made to recordingStatusCallback contains the track attribute to indicate which audio track was recorded. It is recommended to subscribe to the recordings callback in order to know which audio track has been chosen.

You can also check this information from the Recordings Logs section(link takes you to an external page) and Recording details page within the Programmable Voice area in the Twilio Console.

Need some help?

Terms of service

Copyright © 2024 Twilio Inc.