Skip to contentSkip to navigationSkip to topbar
Rate this page:
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

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

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 Call

Ensure to set both Record and RecordingTrack

Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_22
// Download the helper library from https://www.twilio.com/docs/node/install
_22
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_22
_22
// Find your Account SID and Auth Token at twilio.com/console
_22
// and set the environment variables. See http://twil.io/secure
_22
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_22
const authToken = process.env.TWILIO_AUTH_TOKEN;
_22
const client = twilio(accountSid, authToken);
_22
_22
async function createCall() {
_22
const call = await client.calls.create({
_22
from: "+14155552344",
_22
record: true,
_22
recordingTrack: "outbound",
_22
to: "+14155552345",
_22
url: "https://www.example.com",
_22
});
_22
_22
console.log(call.sid);
_22
}
_22
_22
createCall();

Output

_39
{
_39
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_39
"annotation": null,
_39
"answered_by": null,
_39
"api_version": "2010-04-01",
_39
"caller_name": null,
_39
"date_created": "Tue, 31 Aug 2010 20:36:28 +0000",
_39
"date_updated": "Tue, 31 Aug 2010 20:36:44 +0000",
_39
"direction": "inbound",
_39
"duration": "15",
_39
"end_time": "Tue, 31 Aug 2010 20:36:44 +0000",
_39
"forwarded_from": "+141586753093",
_39
"from": "+14155552344",
_39
"from_formatted": "(415) 867-5308",
_39
"group_sid": null,
_39
"parent_call_sid": null,
_39
"phone_number_sid": "PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_39
"price": "-0.03000",
_39
"price_unit": "USD",
_39
"sid": "CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_39
"start_time": "Tue, 31 Aug 2010 20:36:29 +0000",
_39
"status": "completed",
_39
"subresource_uris": {
_39
"notifications": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications.json",
_39
"recordings": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings.json",
_39
"payments": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Payments.json",
_39
"events": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Events.json",
_39
"siprec": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Siprec.json",
_39
"streams": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Streams.json",
_39
"transcriptions": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Transcriptions.json",
_39
"user_defined_message_subscriptions": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/UserDefinedMessageSubscriptions.json",
_39
"user_defined_messages": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/UserDefinedMessages.json"
_39
},
_39
"to": "+14155552345",
_39
"to_formatted": "(415) 867-5309",
_39
"trunk_sid": null,
_39
"uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json",
_39
"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.

Record a side of an ongoing call

Use the Call Recording Controls to start and configure the recording

Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_18
// Download the helper library from https://www.twilio.com/docs/node/install
_18
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_18
_18
// Find your Account SID and Auth Token at twilio.com/console
_18
// and set the environment variables. See http://twil.io/secure
_18
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_18
const authToken = process.env.TWILIO_AUTH_TOKEN;
_18
const client = twilio(accountSid, authToken);
_18
_18
async function createCallRecording() {
_18
const recording = await client
_18
.calls("CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_18
.recordings.create({ recordingTrack: "inbound" });
_18
_18
console.log(recording.accountSid);
_18
}
_18
_18
createCallRecording();

Output

_20
{
_20
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_20
"api_version": "2010-04-01",
_20
"call_sid": "CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_20
"conference_sid": null,
_20
"channels": 2,
_20
"date_created": "Fri, 14 Oct 2016 21:56:34 +0000",
_20
"date_updated": "Fri, 14 Oct 2016 21:56:34 +0000",
_20
"start_time": "Fri, 14 Oct 2016 21:56:34 +0000",
_20
"price": null,
_20
"price_unit": null,
_20
"duration": null,
_20
"sid": "REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_20
"source": "StartCallRecordingAPI",
_20
"status": "in-progress",
_20
"error_code": null,
_20
"encryption_details": null,
_20
"track": "both",
_20
"uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings/REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json"
_20
}

Configure recording party when adding a new participant to a conference

Ensure to set both Record and RecordingTrack

Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_23
// Download the helper library from https://www.twilio.com/docs/node/install
_23
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_23
_23
// Find your Account SID and Auth Token at twilio.com/console
_23
// and set the environment variables. See http://twil.io/secure
_23
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_23
const authToken = process.env.TWILIO_AUTH_TOKEN;
_23
const client = twilio(accountSid, authToken);
_23
_23
async function createParticipant() {
_23
const participant = await client
_23
.conferences("ConferenceSid")
_23
.participants.create({
_23
from: "+14155552344",
_23
record: true,
_23
recordingTrack: "inbound",
_23
to: "+14155552345",
_23
});
_23
_23
console.log(participant.accountSid);
_23
}
_23
_23
createParticipant();

Output

_17
{
_17
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_17
"call_sid": "CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_17
"label": "customer",
_17
"conference_sid": "ConferenceSid",
_17
"date_created": "Fri, 18 Feb 2011 21:07:19 +0000",
_17
"date_updated": "Fri, 18 Feb 2011 21:07:19 +0000",
_17
"end_conference_on_exit": false,
_17
"muted": false,
_17
"hold": false,
_17
"status": "queued",
_17
"start_conference_on_enter": true,
_17
"coaching": false,
_17
"call_sid_to_coach": null,
_17
"queue_time": "1000",
_17
"uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json"
_17
}

Configure recording party using <Dial>

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.

Record only the inbound track of the call

Node.js
Python
C#
Java
PHP
Ruby

_11
const VoiceResponse = require('twilio').twiml.VoiceResponse;
_11
_11
const response = new VoiceResponse();
_11
const dial = response.dial({
_11
record: 'record-from-answer',
_11
recordingTrack: 'inbound',
_11
recordingStatusCallback: 'https://www.myexample.com/recording-handler'
_11
});
_11
dial.number('+15551239876');
_11
_11
console.log(response.toString());

Output

_10
<Response>
_10
<Dial record="record-from-answer"
_10
recordingTrack="inbound"
_10
recordingStatusCallback="https://www.myexample.com/recording-handler">
_10
<Number>+15551239876</Number>
_10
</Dial>
_10
</Response>


How to determine which track has been recorded

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 and Recording details page within the Programmable Voice area in the Twilio Console.


Rate this page: