twiliotwilio-apitwilio-node

cant play audio url with twilio play


i try to do a simple call phone from twilio that play a massage and hang up, but no matter what url i put, when the call made i get a voice massage about function error here is my code:

let twilio = require('twilio');

var accountSid =; // Your Account SID from www.twilio.com/console
var authToken = ;   // Your Auth Token from www.twilio.com/console

var client = new twilio(accountSid, authToken);

const VoiceResponse = require('twilio').twiml.VoiceResponse;


const response = new VoiceResponse();
response.play({
    loop : 1,
},"https://scribie.com/records/7941e240b8884865872ac859e389927b78757fae_orig.mp3?fn=test2.mp3&to=FHtRpSzUlmmaVRWjl7n23mC3Ezm5nYwK");

console.log(response.toString());

client.calls
    .create({
        twiml: response.toString(),
        to: '',
        from: ''
    }).then(call => console.log(call.sid)).catch(e=>console.log(e));

Solution

  • Twilio developer evangelist here.

    I can get your code to work when I replace the Scribie URL with "http://demo.twilio.com/docs/classic.mp3". When I try to open up the Scribie URL you have, it takes me to this webpage one has to log-in to view. Instead of that, I'd try uploading the file to Twilio Assets or a different hosting service.