We've been working on browser to phone as per the doc provided by twilio which is in C# razor. We have to same the same for our clients using asp.net4.0.
When a phone number is entered in the textbox the call gets forwarded to the number that is specified in the VoiceURL of the TWIMLAPP rather than forwarding it to the number entered in the textbox.
Below listed are some of the queries that are haunting us;
How do we create dynamic TWIML's to pass the phone number to the Dial Verb?
How to over write the VoiceURL of the TWIML app programmatically?
Are there any examples in asp.net 4.0?
Twilio evangelist here.
Lets take your questions one at a time.
How do we create dynamic TWIML's to pass the phone number to the Dial Verb?
TwiML is just XML, so there are a number of ways to dynamically generate XML in .NET. We do provide a special library (available on NuGet) called Twilio.TwiML that will generate the TwiML for you to return to Twilio. I wrote a blog post a while ago that shows you how to use it.
If you want to generate a <Dial> verb using the TwiML library, you would do something like:
var response = new TwilioResponse();
response.Dial(phoneNumber);
string xml = response.ToString();
How to over write the VoiceURL of the TWIML app programmatically?
The Twilio REST API can be used to modify a TwiML Application. The Twilio .NET helper library makes it easy to do this as well:
var client = new TwilioRestClient("[YOUR_ACCOUNT_SID]","[YOUR_AUTH_TOKEN]");
client.UpdateApplication(applicationSid, friendlyName, applicationOptions);
Hope that helps.
Related
While using Make a Call api, Twilio requires to input URL of an XML which should contain <say> element, which will convert the text into speech. I want to rather pass say, action and method (action and method attributes of Gather element) as an object. Is there a possibility in Twilio api? I want to receive some Digits entered by user during this call. Kindly help.
Twilio developer evangelist here.
When making a call you always need to pass a URL that when called will return some XML (TwiML) to tell Twilio what to do with the call.
If you are looking to receive digits entered by a user, you will need to include the <Gather> verb in that XML. If you want a bit more detail than just the documentation, there is a tutorial available that takes you through building a phone menu system using C# that you might find helpful in this case. The tutorial starts with an incoming call, but the theory regarding <Gather> is the same.
I am trying to make an outgoing call using Twilio and C#.
I gave the (fromnumber, tonumber, twiliodemourl) as 3 parameters for initiate
outbound call.Then it is working with default twilio demo voice content.
Now i need to customize the voice content attribute and some other attributes
every time i trigger the initiate outbound call method
I have gone through Twilio docs i did not find any good option for customize the
content dynamically from the code using C# every time i send the request.
My client application running periodically to verify for any new messages and then
trigger initiateoutboundcall.
I don't have any custom URL to post any new XML which voice is looking for in 3rd
parameter of initiateOutBoundCall.
So is it required a external domain URL to customize the voice content dynamically from code?
If no please provide the options/sample i have to do it from C# console application.
I tried to use the twimlets.com to echo the custom text to speak in the call.
For text change it is working fine with custom text. But i am not sure whether twimlets.com/echo can be used for production use? Please confirm. Twimlets is not supporting some of the features which i am looking for like Gather input
like IVR message for outbound call.
Using Twilio Voice and C# client:
Voice Request using Twilio C# client?
Dial the number with custom voice content(). If user not responds leave a
voice mail with the custom voice content().
Dial the number with custom voice content (). If user responds, after reading
the message need to provide options like:
press 1 for repeat the same voice message.
press 2 to confirm the action on the message.
press 3 to send SMS for the voice message.
Need to get the response for each voice call / message?
For the sms it send i am getting response as "queued" instead of message sent.
Based on the SMS sent successfully or not i need to update some flag.
So how i can get the SMS reponse as "sent".
SMSMessage sms = twilio.SendSmsMessage(sFromNumber, sToNumber, sMessage);
Console.WriteLine("SMS Status::::::" + sms.Status);
Similarly I need the reponse for voice call once the call is ring id done.
But it is giving "queued".
var call = twilio.InitiateOutboundCall(sFromNumber,sToNumber, url);
Console.WriteLine("Call Status" + call.Status);
So please provide me options for doing it using Twilio.
It would be great if you provide any sample example using C#.
Twilio evangelist here.
You do need some kind of public URL that Twilio can make an HTTP request to once the outbound call is answered. This is how Twilio gets the instructions it needs in order to proceed with the live, in-progress call.
As you noted there are a number of free options for hosting static TwiML content. Twimlets is one. Twimlbin.com is another. Both services are free and great places to at least get started prototyping or setting up a simple MVP of your application, but bear in mind that if you expect a large amount of traffic or you need to build something with your own custom logic in it you'll probably want to move to something else.
That something else could be your own website hosted as as Azure Website (which you can also get for free). Moving to your own website also means that you can scale it as needed and you can start serving up dynamically generated TwiML instead of just being limited to dynamic TwiML as you basically are with Twimlets or Twimlbin.
If you want to process input from <Gather> and none of the Twimlets meet your needs, then you will likely need to look at the Azure option (or some kind of hosted website, doesn't have to be Azure). This will let you build your own custom logic in order to process the callers input and dynamically generate a TwiML response based on that logic.
Twilio provides helper libraries for TwiML generation and for building Twilio apps using ASP.NET MVC, which you can get from NuGet.
Lets say you want to go down the road of building you own custom Twilio app using ASP.NET MVC and hosting it using an Azure Website. In that scenario, using our helper libraries you could build an action method in your controller that returns the TwiML with the <Say> and <Gather> verbs. Something like:
var response = new TwilioResponse();
response.Say("Hello World");
response.BeginGather(new { action="http://example.azurewebsites.com/gather/" } );
response.EndGather();
You would provide the URL that executes that action method as the third parameter in the initiaizeOutboundCall method eg:
client.IntializeOutboundCall(FROM, TO, "http://example.azurewebsites.net");
Once the user enters their input, Twilio will request the URL you specified in the <Gather> verbs action parameter passing you an extra HTTP parameter named Digits, which you can grab in your action method and use in your app logic:
public void Gather(string Digits) {
var response = new TwilioResponse();
response.Say("You pressed " + Digits);
return TwiML(response);
}
To get the status of a phone call or an SMS, you can include use the statuscallback parameter:
SMS: var result = client.SendMessage(FROM, TO, BODY, "http://example.azurewebsites.net/status");
Voice: var result = client.InitiateOutboundCall(FROM, TO, VOICEURL, "http://example.azurewebsites.net/status");
Twilio will make HTTP request to the statusCallback URL's once the final status of the message or call is reached.
Hope that helps.
As of version 5.32 of the C# SDK, you can pass a dynamic twiml string into the CallResource.Update() method like so:
CallResource.Update(
twiml: "<Response><Say>Custom Message Here</Say></Response>"
pathSid: call.Sid);
Or even:
string customMessage = "<Response><Say>Custom Message Here</Say></Response>"
CallResource.Update(
twiml: customMessage,
pathSid: call.Sid);
How do you use the Twilio sandbox mode with C#? I have a ashx.cs file that I am using to write my code. Would I put it there? If so, what does that look like?
There is no real great examples on their website on how to do this except for CURL and Ruby.
We are using TwiML to general an XML file tha t parses our data to send back and forth to the Twilio service. We don't want to be charged every time we send a test text message.
How would we set the Sandbox up so we could do some testing.
I found the Test auth Token and account Sid, but how do I use those?
We don't have them in our current application and we are specifying our .ashx page in Twilio to process our code.
Thanks in advance.
Twilio evangelist here.
So if you just want to test that your ASHX handler is generating the right results the easiest way to do this is to just fake a POST or a GET request to that handler. This lets you simulate the GET or POST request that Twilio will make to your app when it gets a text message.
You can see the parameters that Twilio will pass to your app when it receives a text message here:
http://www.twilio.com/docs/api/twiml/sms/twilio_request#synchronous
There are a whole bunch of ways to simulate these requests. cURL is one of them. If your ASHX is expecting query string values, you can also just load the ASHX directly in the browser and append those values in the URL. If the handler is expecting a POST request, I used a chrome plugin called Simple REST Client to make these.
Of course you can also Fiddler to make just about any HTTP request.
The Test Credentials really are more for simulating the use of the REST API (programatically sending SMS messages). I just wrote a blog post that shows how to use the test credentials to create integration tests:
http://www.twilio.com/blog/2013/05/automating-twilio-integration-tests-with-test-credentials.html
Hope that helps.
Devin
As of August 15, Amazon made it compulsory to sign all requests made to their Product Advertising API. I thought I had got everything working just fine but when the 15th finally came around, my web application stopped working and pretty much ever since I have been trying to find out how to sign the SOAP requests.
Amazon has an outdated sample code for signing requests that doesn't appear to work here
Basically, I need to know how to add a signature to the my requests using the most current C# SOAP API and .NET 3.5.
I hope I have given enough details, if I haven't please feel free to ask me to elaborate.
Thank You
The_Lorax
UPDATE:
I am using MVC and need to know how to add the Signature to the the ItemLookup or AWSECommerceService object. Is there an attribute that contains the signature value? How does it get attached to the request?
On this page, they say that I must include the Signature and TimeStamp parameters but the intellisense does now show any such attributes.
Check out http://flyingpies.wordpress.com/2009/08/01/17/. It has a walkthrough and a sample visual studio solution using C#, SOAP, WCF on .NET 3.5.
This library automatic sign the requests (Install-Package Nager.AmazonProductAdvertising)
https://www.nuget.org/packages/Nager.AmazonProductAdvertising/
Example:
var authentication = new AmazonAuthentication("accesskey", "secretkey");
var client = new AmazonProductAdvertisingClient(authentication, AmazonEndpoint.US);
var result = await client.SearchItemsAsync("canon eos");
I need to send MMS thought a C# application. I have already found 2 interesting components:
http://www.winwap.com
http://www.nowsms.com
Does anyone have experience with other third party components?
Could someone explain what kind of server I need to send those MMS? Is it a classic SMTP Server?
Typically I have always done this using a 3rd party aggregator. The messages are compiled into SMIL, which is the description language for the MMS messages. These are then sent on to the aggregator who will then send them through the MMS gateway of the Network Operator. They are typically charged on a per message basis and the aggregators will buy the messages in a block from the operators.
If you are trying to send an MMS message without getting charged then I am not sure how to do this, or if it is possible.
You could do it yourself. Some MMS companies just have a SOAP API that you can call. All you need to do is construct the XML and send it off via a URL. I have done this once before, but can't remember the name of the company I used.
This post earlier discussed different approaches for SMS and might be helpful for you.
You could use Twilio to accomplish this. You can dive into the docs for specific implementation details but using the C# helper library the code to send an MMS would look like this:
// Send a new outgoing MMS by POSTing to the Messages resource */
client.SendMessage(
"YYY-YYY-YYYY", // From number, must be an SMS-enabled Twilio number
person.Key, // To number, if using Sandbox see note above
// message content
string.Format("Hey {0}, Monkey Party at 6PM. Bring Bananas!", person.Value),
// media url of the image
new string[] {"https://demo.twilio.com/owl.png" }
);
Disclaimer: I work for Twilio.