How to record a phone call with Twilio
There are multiple ways to record phone calls made and received on your Twilio account:
<Record> in TwiML
You can add the
<Record> verb to the TwiML file that Twilio fetches after we connect your phone call. Use this approach if you want to record one person talking. This is how you would build a voicemail system, or a phone poll that asked users to record something.
Twilio will return a url pointing to your <Record> recording if you make sure to specify an
action url on the <Record>. For more information, see our documentation on the <Record> verb in TwiML.
<Dial record=”record-from-answer”> or <Dial record=”record-from-ringing”> in TwiML
You can use either attribute mentioned above when you’re connecting a call via the <Dial> verb. Use this method if you want to record both sides of a conversation. This is how you would record a forwarded call, or any type of call based on <Dial>.
Twilio will return a url pointing to your <Dial> recording if you make sure to specify an
action url on the <Dial>. For more information, see our documentation on the <Dial> verb in TwiML.
<Conference record=”record-from-start”> in TwiML
Use the attribute above if you want to record the entirety of your conference call. This type of recording will start only when a conference is bridged, i.e. when participants are able to talk to each other. If you’d like to start your recording as soon as the <Dial> starts, use one of the <Dial> recording parameters noted above. Note that you can specify record on <Dial> as well as on <Conference> which will return two separate recordings.
Twilio will return a url pointing to your <Conference> recording if you make sure to specify an
eventCallbackUrl on the <Conference>. For more information, see our documentation on the <Conference> noun in TwiML.
Record=”true” in REST API
You can append the parameter
"Record=true" when making a
POST request for Twilio to make an outgoing call via the REST API. Use this if you want to record the entirety of an outgoing call.
Twilio will return a url pointing to your REST API call recording if you make sure to specify an
StatusCallback on API request. For details on how to use this parameter and proper formatting guidelines, see our documentation on placing an outgoing call with the REST API.
Recording calls on your outbound Elastic SIP trunk
You can configure your outbound Elastic SIP trunk to record all of your calls that go over your trunk. You can choose to set the recording functionality to “Record from Ringing” or “Record from Answer”. To configure your trunk go to your list of Outbound SIP Trunks in the Console, click on the trunk you want to configure and select your desired setting under the “Call Recording” section.
Hosting your TwiML
You can write TwiML and host it on a server of your choosing, but you also have the option to use Twilio as your host if you’ve coded up a simple recording script using just TwiML. To use Twilio as your host, we’ll use a tool called TwiML Bins that you can find in your Console. Simply create a new Bin to paste your code into and then save it to one of your Twilio numbers.