1
votes

I'm trying to use TwiML to (upload, convert and then) play a .aifc format welcome greeting for a Twilio Voicemail, before then recording any message from the caller. My current code is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<Response>
   <Play>
https://drive.google.com/file/*********
    </Play>
    <Say>
Press * or hang up when you have finished recording.</Say>
    <Record action="http://foo.edu/handleRecording.php" method="GET" maxLength="45" finishOnKey="*"/>
</Response>

The code worked before I tried to use the <Play> function.. making me wonder whether hosting the file on Google Drive is the issue. Previously I used <Say>, but that sounded pants.

Any suggestions greatly received.

2
I think some of the code you tried to post here didn't go through. Could you please post the entire TwiML so I can have a look? ThanksMarcos Placona
Thanks Marcos. Corrected now.jmp1979
Is the Google Drive link a direct link to the audio file itself? If you attempt to request the URL from an private browser session do you get the file, asked to login or a page that shows the file can be downloaded?philnash
Hi Phil, Yes - The Google Drive URL was the shareable link generated from within Drive through Chrome. If I access the URL in an incognito Chrome session it is accessible without logging in, but only after I have acknowledged a 'Your browser is unable to play this file" message and clicked a 'Download' button.jmp1979
Hi @jmp1979 check my answer belowMarcos Placona

2 Answers

0
votes

Twilio developer evangelist here.

For Twilio to be able to play a file, it is necessary that this file is accessible from within your browser and without any form of login or confirmation on the screen.

An example of such file is this one: https://api.twilio.com/cowbell.mp3.

But here's how you can test that:

In your terminal (making the assumption you have curl installed) run:

curl -v https://api.twilio.com/cowbell.mp3

This will output a bunch of binary information, which is for your music file.

If you then upload that same MP3 file to Google Drive and try to do the same with the shareable URL, you will see that an HTML file is return. A big old HTML file as a matter of fact.

Twilio is getting that file, and thus returning the error "TwiML response body too large - Error - 11750" because it is trying to append that HTML returned to your TwiML.

Hope this help you.

0
votes

I was getting the same error, audio file was https://api.twilio.com/cowbell.mp3 and xml response was less than 1KB and i was using Twilio PHP SDK with this code to generate the xml and also header type as 'text/xml'.

$response = new VoiceResponse();
$response->play('https://api.twilio.com/cowbell.mp3');

What worked for me was to save the $response (which is xml generated by php sdk ) in a file voice.xml and use that file url when calling and it worked.