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.
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.
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:
RecordingTrack | RecordingChannel | Outcome |
---|---|---|
- | - | Records the inbound and the outbound audio of the call mixed in a single channel of the recording file. |
- | mono | Records the inbound and the outbound audio of the call mixed in a single channel of the recording file. |
- | dual | Records 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. |
inbound | 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. |
inbound | dual (→ 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. |
outbound | 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. |
outbound | dual (→ 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. |
both | mono | Records the inbound and the outbound audio of the call mixed in a single channel of the recording file. |
both | dual | Records the inbound and the outbound audio of the call in two separate channels of the recording file |
You can enable single party recording for any given call using the following Twilio's Programmable Voice APIs:
This feature is not yet available in TwiML <Record> or <Conference>. SIP Trunking calls also do not currently support this functionality.
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function createCall() {11const call = await client.calls.create({12from: "+14155552344",13record: true,14recordingTrack: "outbound",15to: "+14155552345",16url: "https://www.example.com",17});1819console.log(call.sid);20}2122createCall();
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}
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/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function createCallRecording() {11const recording = await client12.calls("CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")13.recordings.create({ recordingTrack: "inbound" });1415console.log(recording.accountSid);16}1718createCallRecording();
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}
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function createParticipant() {11const participant = await client12.conferences("ConferenceSid")13.participants.create({14from: "+14155552344",15record: true,16recordingTrack: "inbound",17to: "+14155552345",18});1920console.log(participant.accountSid);21}2223createParticipant();
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}
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:
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.
1const VoiceResponse = require('twilio').twiml.VoiceResponse;23const response = new VoiceResponse();4const dial = response.dial({5record: 'record-from-answer',6recordingTrack: 'inbound',7recordingStatusCallback: 'https://www.myexample.com/recording-handler'8});9dial.number('+15551239876');1011console.log(response.toString());
1<Response>2<Dial record="record-from-answer"3recordingTrack="inbound"4recordingStatusCallback="https://www.myexample.com/recording-handler">5<Number>+15551239876</Number>6</Dial>7</Response>
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.