The following twiml used to work a few years ago for recording calls:
<?php
header("content-type: text/xml");
?>
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Say voice="woman" language="en-gb">This call may be recorded for quality assurance.</Say>
<Dial record='true' action='https://URL.TLD/TWIML/record.php' method='post'>+15555555555</Dial>
</Response>
Now it returns an empty recording link. Revisiting the Twilio documentions lead me to this which says the recording may not be ready right away and to use recordingStatusCallback
<Dial record='true' action='https://URL.TLD/TWIML/do-something.php' recordingStatusCallback = 'https://the-url-thats-supposed-to-do-something-with-the-actual-recording.php' method='post'>+15555555555</Dial>
The problem I'm having is that recordingStatusCallback
doesn't say what number the call came from. I tried saving it to a $_SESSION
variable, but Twilio isn't passing the session ID when it requests the callback url.
Twilio does pass a CallSid
, which could be written to a file or database, and then subsequently pulled, matching on the Sid to the caller's phone number, but isn't there some other way to tie the caller's phone number to the actual recording being made?