I'm looking to make an outbound call in a Java application using Twilio. All of the tutorials I found used a static TwiML file hosted on a URL. I haven't been able to find any documentation on how to pass in TwiML as a parameter for an outgoing call.
I found this on this link, but it doesn't explain how to dynamically render TwiML: https://www.twilio.com/docs/guides/how-to-make-outbound-phone-calls-in-java#where-to-next
Of course, the TwiML you use to make the outbound call doesn't need to be a static file like in this example. Server-side Java code that you control can dynamically render TwiML to use for the outbound call.
I've tried the following:
PhoneNumber to = new PhoneNumber(toPhone); // Replace with your phone number
PhoneNumber from = new PhoneNumber(fromPhone); // Replace with a Twilio number
TwiML twiml = new VoiceResponse.Builder()
.say(new Say.Builder(message).build())
.build();
Call call = Call.creator(to, from, twiml.toXml()).create(client);
While the Call.creator()
has some overloaded methods of (PhoneNumber, PhoneNumber, String)
, none of them will accept TwiML, nor XML.
How do make an outbound call in Java using TwiML? Thanks