The sample code on how-to-make-a-call looks like this:
static void Main(string[] args)
{
// Find your Account Sid and Auth Token at twilio.com/console
const string accountSid = "ACc610c3a41a31c91a01396f7bf92c517d";
const string authToken = "your_auth_token";
TwilioClient.Init(accountSid, authToken);
var to = new PhoneNumber("+14155551212");
var from = new PhoneNumber("+15017122661");
var call = CallResource.Create(to,
from,
url: new Uri("http://demo.twilio.com/docs/voice.xml"));
Console.WriteLine(call.Sid);
}
The xml of the referenced voice.xml looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Say voice="alice">Thanks for trying our documentation. Enjoy!</Say>
<Play>http://demo.twilio.com/docs/classic.mp3</Play>
</Response>
I would like to just create an xml file in memory, and reference that, rather than a remote uri. Is there anyway to take something like the below and attach it to the CallResource.Create argument?
System.Xml.XmlDocument xmlDocument = new XmlDocument();
String s = "My custom message!";
xmlDocument.LoadXml(string.Format(@"<Response><Say voice=""alice"">{0}</Say></Response>", s));
Twilio developer evangelist here.
Currently there is no way to send the TwiML for a call with the request to create the call. You do need the TwiML to be hosted somewhere.
If it would be difficult for you to host TwiML, then you could look into TwiML Bins or Twilio Functions for static and dynamic ways of hosting TwiML within Twilio.