Use a fluent interface to generate TwiML responses for use by Twilio.
public virtual ActionResult Index()
{
return new TwilioResult(r =>
{
r.Gather(Url.Action("ChooseItem"), HttpMethod.POST, 1, null, null,x =>
{
x.Say("You Have reached Our Company");
x.Say("If you know your partie's extention, you may dial it at any time.");
x.Say("For Sales, Press 1");
x.Say("For Billing, Press 2");
x.Say("For Support, Press 3");
x.Say("For a Company Directory, Press 4");
x.Say("To Repeat these options, Press 9");
x.Pause(5);
});
r.Redirect(Url.Action("Index"));
});
}
Generates: <Response> <Gather action=“/Twilio/ChooseItem” method=“POST” timeout=“1”> <Say>You Have reached Our Company</Say> <Say>If you know your partie’s extention, you may dial it at any time.</Say> <Say>For Sales, Press 1</Say> <Say>For Billing, Press 2</Say> <Say>For Support, Press 3</Say> <Say>For a Company Directory, Press 4</Say> <Say>To Repeat these options, Press 9</Say> <Pause length=“5” /> </Gather> <Redirect>/Twilio</Redirect> </Response>
You can also access all of the parameters from a call within a controller: private TwilioResult NightTimeMenu()
{
var from = this.TwilioRequestParams().From;
var apiVersion = this.TwilioRequestParams().ApiVersion;
var accountSid = this.TwilioRequestParams().AccountSid;
...
}
Copyright © 2010 Chris Kooken and contributors. See LICENSE for details.