Back to blog

Twilio Call Recording: How to Set It Up and Get Structured Data Out

A practical guide to recording calls with Twilio: TwiML Record, dual-channel Dial recording, the REST API, recordingStatusCallback webhooks, and how to turn recordings into structured data.

HearLoc8 min read

In short

Three ways to record with Twilio: TwiML <Record> for voicemail-style capture, record="record-from-answer-dual" on <Dial> for two-sided calls, or record: true via the REST API. Get the file with recordingStatusCallback, then send it to transcription or extraction.

A phone handset with sound waves flowing into code brackets, representing Twilio call recording and webhooks

Twilio gives you three different ways to record a call, and picking the wrong one is the most common reason recordings come out one-sided, cut short, or missing entirely. This guide covers all three, the webhook that tells you the recording is ready, and what to do with the audio afterwards — because a raw MP3 is rarely the thing you actually need.

Option 1: TwiML <Record> — voicemail-style capture

The <Record> verb records whatever the caller says after it executes. It is the right tool for voicemails, message lines, and single-sided capture. It is the wrong tool for conversations — it records one leg only.

<?xml version="1.0" encoding="UTF-8"?>
<Response>
  <Say>This call may be recorded for quality and service purposes.</Say>
  <Record maxLength="120"
          playBeep="true"
          recordingStatusCallback="https://example.com/recording-done"/>
</Response>

Note the consent line before the recording starts. If you operate across US states, treat every call as all-party consent — announce it, always.

Option 2: recording a real two-sided conversation

For an actual phone conversation — an inbound customer call bridged to your team, or an outbound call — put the record attribute on <Dial>. Use the dual variant so each side lands on its own channel; every transcription engine downstream will thank you for it.

<Response>
  <Say>This call may be recorded for quality and service purposes.</Say>
  <Dial record="record-from-answer-dual"
        recordingStatusCallback="https://example.com/recording-done">
    <Number>+15551234567</Number>
  </Dial>
</Response>

record-from-answer starts when the callee picks up (no ringing in your audio); the -dual suffix gives you a two-channel file with the caller on one channel and your team on the other. Dual-channel audio noticeably improves transcription accuracy and makes speaker attribution trivial.

Option 3: the REST API

When you create calls programmatically, turn recording on in the same request:

const client = require('twilio')(accountSid, authToken);

const call = await client.calls.create({
  to: '+15551234567',
  from: '+15557654321',
  url: 'https://example.com/twiml',
  record: true,
  recordingChannels: 'dual',
  recordingStatusCallback: 'https://example.com/recording-done',
  recordingStatusCallbackEvent: ['completed'],
});

You can also start a recording on a live call by POSTing to the call's Recordings resource — useful when recording should begin only after a consent confirmation.

Getting the file: recordingStatusCallback

Do not poll for recordings. Twilio calls your webhook when the file is ready:

app.post('/recording-done', express.urlencoded({ extended: false }), async (req, res) => {
  const { RecordingSid, RecordingUrl, CallSid, RecordingDuration } = req.body;

  // The media file lives at RecordingUrl + '.mp3' (or '.wav')
  const audio = await fetch(RecordingUrl + '.mp3', {
    headers: {
      Authorization: 'Basic '
        + Buffer.from(accountSid + ':' + authToken).toString('base64'),
    },
  });

  // ...store it, or forward it to transcription/extraction
  res.sendStatus(200);
});

Two production notes. First, validate the X-Twilio-Signature header on this endpoint so only Twilio can call it. Second, decide your retention policy up front: recordings billed and stored in Twilio forever are a cost and a liability; many teams download, process, and delete.

The part nobody tells you: the MP3 is not the goal

Almost nobody wants an audio file. They want what was said on the call — and usually one specific thing: the appointment, the phone number, the address. You have three routes from audio to structured data. Build it yourself with a speech-to-text API plus an LLM extraction step plus validation — flexible, but you own accuracy, edge cases, and maintenance. Use Twilio Conversational Intelligence — good built-in operators for sentiment and entities, though generic entities are not validated, dispatch-ready data. Or send the recording to a purpose-built extraction service.

For the address case specifically: HearLoc consumes Twilio recordings directly — you point recordingStatusCallback at your HearLoc ingest URL (generated in the dashboard, signature-validated), and each recording comes back as a verified, dispatch-ready address: extracted, role-labeled, validated against Google, with gate codes and unit numbers captured and only the uncertain results flagged for review. Supported today; no code beyond the webhook URL.

# In your Twilio console or TwiML, set:
recordingStatusCallback = https://hearloc.com/api/v1/integrations/twilio/ingest/<your-token>

# Every completed recording is then processed automatically;
# results arrive in your dashboard, by signed webhook, or via the REST API.

Consent, in one paragraph

Recording laws vary by state; several require all-party consent. The safe default for any multi-state operation: play a recording notice at the start of every call and keep that notice inside the recording itself. We wrote a separate practical guide on US call-recording consent — linked below.

Frequently asked questions

How do I record a call in Twilio?

Three ways: the TwiML <Record> verb for voicemail-style one-sided capture, record="record-from-answer-dual" on <Dial> for two-sided conversations, or record: true when creating a call via the REST API. For conversations, use the Dial method with dual channels.

How do I get the recording file after the call?

Set recordingStatusCallback to your webhook URL. Twilio POSTs RecordingSid and RecordingUrl when the file is ready; fetch RecordingUrl + ".mp3" with your account credentials. Validate the X-Twilio-Signature header on the endpoint.

What is the difference between record-from-answer and record-from-ringing?

record-from-answer starts recording when the call is answered, so you do not capture ringing and early media; record-from-ringing starts earlier. The -dual variants put each party on a separate audio channel, which materially improves downstream transcription.

Can Twilio turn a recording into a transcript or an address?

Twilio offers transcription and Conversational Intelligence operators for generic entities. For validated, dispatch-ready addresses specifically, a purpose-built service like HearLoc ingests Twilio recordings via recordingStatusCallback and returns role-labeled, Google-validated addresses with access notes.

Do I need consent to record customer calls?

Yes. US consent rules vary by state and several require all-party consent, so the safe multi-state default is announcing the recording at the start of every call and keeping the notice in the recording. This is general information, not legal advice.

Related

Turn your recorded calls into verified addresses

HearLoc extracts and validates every address mentioned in a call recording, with confidence scores and review flags — by API or straight from your phone provider.

Start free trial