user2138160
user2138160

Reputation: 279

How to initiate an outgoing call with message?

I'm trying to notify the caller with an automated message. Here is my code below. string

        string AccountSid = "***************";
        string AuthToken = "**************";

        var doc = new XDocument();
        var call = new XElement("call");

        call.Add(new XElement("Say", Message));

        doc.Add(call);


        var twilio = new TwilioRestClient(AccountSid, AuthToken);

        var options = new CallOptions();
        options.Url = doc.ToString(); //Don't have URL need to add XML doc instead
        options.To = Phone;
        options.From = "********";
        var callnow = twilio.InitiateOutboundCall(options);

Upvotes: 0

Views: 216

Answers (1)

xmjw
xmjw

Reputation: 3434

Twilio Developer Evangelist here.

You cannot add the XML into the CallOptions as shown in the code above. You do need to find a way to place your TwiML into an XML document on a URI accessible by Twilio.

If the message is not dynamic to the call, you could host a static XML file containing TwiML on a service such as Amazon's S3. I have occasionally used Dropbox Public URLs, but only for testing at low volume. But there are lots of options available, including the TwiMLBin service. But if your message is dynamic in any way, you are going to need an application that can respond to HTTP requests.

Is there some particular constraint you have, maybe I can suggest a work around?

Hope this helps!

Upvotes: 1

Related Questions