How to record a single side of a call
Learn to programmatically record only one side of a call with Twilio Programmable Voice by using the RecordingTrack parameter in a POST request. You can use this guide to create self-service automation, inbound contact centers, outbound contact centers, sales dialers, call tracking systems, and AI/ML transcription.
See Related reference documentation to learn more about the TwiML and API requests used in this guide.
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
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:
Info
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();
Response
1{2"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",3"answered_by": null,4"api_version": "2010-04-01",5"caller_name": null,6"date_created": "Tue, 31 Aug 2010 20:36:28 +0000",7"date_updated": "Tue, 31 Aug 2010 20:36:44 +0000",8"direction": "inbound",9"duration": "15",10"end_time": "Tue, 31 Aug 2010 20:36:44 +0000",11"forwarded_from": "+141586753093",12"from": "+14155552344",13"from_formatted": "(415) 867-5308",14"group_sid": null,15"parent_call_sid": null,16"phone_number_sid": "PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",17"price": "-0.03000",18"price_unit": "USD",19"sid": "CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",20"start_time": "Tue, 31 Aug 2010 20:36:29 +0000",21"status": "completed",22"subresource_uris": {23"notifications": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications.json",24"recordings": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings.json",25"payments": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Payments.json",26"events": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Events.json",27"siprec": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Siprec.json",28"streams": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Streams.json",29"transcriptions": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Transcriptions.json",30"user_defined_message_subscriptions": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/UserDefinedMessageSubscriptions.json",31"user_defined_messages": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/UserDefinedMessages.json"32},33"to": "+14155552345",34"to_formatted": "(415) 867-5309",35"trunk_sid": null,36"uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json",37"queue_time": "1000"38}
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/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();
Response
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();
Response
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:
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.
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());
Output
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 call recordings log in Twilio Console or the legacy Console.
This guide teaches the basics required for the following use cases:
You can use this guide to record only the caller's side of the interaction when they interact with an IVR. This allows you to analyze customer responses without including the automated prompts in the recording file.
To learn more advanced features that you can use with self-service automation, see Voice self-service automation.
You can use this guide to record specifically the agent or the customer side of a call. This is useful for quality assurance and training purposes where individual track isolation is required.
To learn more advanced features that you can use with inbound contact centers, see Voice inbound contact center.
You can use this guide to isolate the audio of your agents during outbound campaigns. Recording a single track simplifies the process of reviewing agent performance and compliance.
To learn more advanced features that you can use with outbound contact centers, see Voice outbound call center.
You can use this guide to record sales pitches or customer feedback during outbound sales calls. Isolating tracks helps in cleaning up audio for CRM logging and sales coaching.
To learn more advanced features that you can use with sales dialers, see Voice sales dialer.
You can use this guide to record and analyze specific participants in a tracked call. This helps in identifying which party initiated specific keywords or sentiments during the conversation.
To learn more advanced features that you can use with call tracking, see Voice call tracking.
You can use this guide to capture clean, single-sided audio for high-accuracy AI transcription. By isolating the inbound track, you ensure that the machine learning model only processes the speaker's voice without background noise or Twilio-generated audio.
To learn more advanced features that you can use with AI or ML transcription, see Voice AI/ML transcription.
After following this guide, you can programmatically record a single side of a call using Twilio Programmable Voice. You can verify this by checking the track attribute in your recordingStatusCallback or by viewing the recording logs in the Twilio Console to confirm only one audio track was captured.
Explore the following guides to build on what you've learned in this guide:
- Record phone calls: Learn the fundamentals of recording entire calls with Twilio.
- Create conference calls: Understand how to manage and record multi-party conversations.
- Voice recording encryption: Secure your recording files using public key encryption.