I'm trying to create a POC for a friend using twilio. The POC consists of 2 things
1
Present text box for phone number Call number using Twilio Record and transcribe call for 10 seconds Present transcription and link to recording on web page End
2
Present text box for phone number Call number using Twilio Listen for digits (DTMF) Display digits pressed on web page End
I think I have #1 but im kind of stuck on #2. So i have a webform proj that has 1 webform page with a textbox and a submit button that calls twillio.
Code
protected void btnSubmit2_Click(object sender, EventArgs e)
{
var twilio = new TwilioRestClient(AccountSid, AuthToken);
var options = new CallOptions();
options.Url = "http://servername/TwilioHandler.ashx"; // this needs to get replaced by DB Public url
options.From = "+17143505676"; // Number that its calling from
options.To = txtBox2.Text; // Number that its calling to
options.Record = true;
var call = twilio.InitiateOutboundCall(options);
if (call.RestException == null)
lblStartTime.Text = string.Format("Started call: {0}", call.Sid);
else
lblEror.Text = string.Format("Error: {0}", call.RestException.Message);
}
the code above basically makes a call to my cell phone.
The TwilioHandler.ashx code
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "application/xml";
TwilioResponse twiml = new TwilioResponse();
twiml.Say("Hi Jeff Berney, Please enter something.");
string digits = context.Request["Digits"] ?? String.Empty;
if (digits == String.Empty)
{
twiml.BeginGather(new
{
action = "http://servername/Twilio.aspx",
numDigits = "1",
method = "GET"
});
twiml.Say("To check the status of an order, press one");
twiml.Say("To receive automated status updates via text message, press two");
twiml.Say("To speak with a customer service representative, press three");
twiml.EndGather();
twiml.Say("Goodbye");
twiml.Hangup();
}
if (digits == "1")
twiml.Redirect("Twilio.aspx?Digits=1", "GET");
//twiml.Say("you pressed one");
if (digits == "2")
twiml.Redirect("Twilio.aspx?Digits=2", "GET");
// twiml.Say("you pressed two");
if (digits == "3")
twiml.Redirect("Twilio.aspx?Digits=3", "GET");
//twiml.Say("you pressed three");
if (digits == "4")
twiml.Redirect("Twilio.aspx?Digits=4", "GET");
//twiml.Say("you pressed four");
if (digits == "5")
twiml.Redirect("Twilio.aspx?Digits=5", "GET");
//twiml.Say("you pressed five");
context.Response.Write(twiml.ToString());
}
This code listens for the user input from the phone and send it back to Twilio.aspx page..My problem is that I need to display that Digit back to the Twilio.aspx page ...but i cant. I tried refreshing the page but that doesnt work.
Any guidance will be helpful.