Reputation: 102
So i am trying to make a call using twilio. I tried the example and it worked.
Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
Call call = Call.creator(
new PhoneNumber("+xxxxxxxxxxxxx"),
new PhoneNumber("+yyyyyyyyyyyyy"),
new URI("http://demo.twilio.com/docs/voice.xml")
)
.setRecord(true)
.create();
System.out.println(call.getSid());
}
And now I want that when the clients answer the phone a voice massage appears and the clients say what it wants and the call ends. To do that, this xml was created.
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Say voice="woman">Please leave a message after the tone.</Say>
<Record maxLength="20" />
</Response>
But when i try to use the url: "file:///C:/Users/user/Documents/NetBeansProjects/work/test.xml" THe program doesnt run and a error appears Exception in thread "main" com.twilio.exception.ApiException: Url is not a valid URL
Does twilio doesn't accept the file url?
If so how can I do it? Thanks.
Upvotes: 1
Views: 1689
Reputation: 21720
Twilio developer evangelist here.
For you to use TwiML, you will need to make sure that it is accessible by Twilio, as it's Twilio who will try to read that XML.
I suggest either generating that TwiML from your application and making it available using something like ngrok, or just host that XML somewhere else that is accessible by Twilio. You could host it in dropbox for example and just make it public, and as long as it's visible, you should be good!
Also, have a look at this to see how to generate TwiML from your app.
Upvotes: 1