0

I want to forward the voicemail recording left on my Twilio account using Twilio studio. I am following the article posted here https://support.twilio.com/hc/en-us/articles/223132287-Forwarding-Recordings-to-Your-Email but I only get empty email without audio recording link. I am new with studio and twilio so I'd appreciate your help. The code I added to my server is the following with the exception of the email address. The name of the file is send.php.

<?php
header('Content-type: text/xml');
echo '<?xml version="1.0" encoding="UTF-8"?>'; 
echo '<Response></Response>';
  
$to = "your-email@example.com"; // Update with your email address
$subject = "Message from {$_REQUEST['From']}";
$message = "To listen to this message, please visit this URL: {$_REQUEST['RecordingUrl']}";
$headers = "From: webmaster@example.com"; // Update with your sending address
mail($to, $subject, $message, $headers);

On my Studio flow I added the "Record Voicemail" widget, then my "IF RECORDING COMPLETE" transition is a HTTP POST request to my file send.php with the code above. Can someone please guide me? I can't find articles or video tutorials. Thanks!

Yarseo
  • 47
  • 5
  • so we know `send.php` is being requested when a person leaves a voicemail as you do end up receiving an e-mail. please try this once yourself to confirm. the e-mail is not "empty" as in the "listen to this message" text is sent but without a link, correct? this means either the `RecordingUrl` variable we're trying to get is not being sent (likely a misconfiguration) or for some reason we're not able to get it. if the e-mail does send and is COMPLETELY blank, as in no text at all this could be a server problem. i want you to check your Twilio logs and confirm the recording exists on Twilio. – John Smith Jan 09 '23 at 11:25
  • @JohnSmith I checked and the recordings do exist on Twilio. I'm sure I am missing some information such as sid and token or something. As I said, I copied and pasted the demo code into the send.php file exactly as it is. I just replaced both email addresses shown. What else should I be providing with the send.php file? – Yarseo Jan 10 '23 at 12:14

1 Answers1

0

(I'm responding as an answer since I can't add a comment)

Is the email body empty, or does it show "To listen to this message, please visit this URL:" followed by nothing?

If it's completely blank, there's an issue with the mail implementation on your server.

You could try changing the message line to the following to see everything that is coming into your script from Twilio, pay attention to the capitalization of the keys:

$message = var_export($_REQUEST,true);

If "RecordingUrl" is missing in the result, it's not being sent by Twilio.

tcbeaton
  • 85
  • 7