Twilio 出站呼叫将数据传回站点 .net
Twilio outbound call passing data back to site .net
我对 Twilio 比较陌生,虽然它看起来是一个很棒的应用程序!
基本上我需要完成的是:
我有一个 .net 应用程序,它可以生成拨出电话并提示对方输入数字 - 如何将该输入(当然只是数字)返回到我的 .aspx 页面以进一步处理它?例如,如果它说 "enter your age" 然后我希望 .aspx 页面在标签中显示他们的年龄。
我目前在页面上有一个按钮发送到运行 twiml 代码的 .ashx 文件,该文件以
结尾
context.Response.Write(twiml.ToString());
context.Response.End();`
类型是"text/xml"
也许我很愚蠢,完全没有抓住要点,但我一辈子都想不出如何做到这一点。
非常感谢您!
西德
这里是 Twilio 开发人员布道者。
您要查找的是 Gather 动词。有了它,您可以获得在通话中输入的数字。因此,当有来电时,您可以 return TwiML 这样:
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Gather timeout="10" finishOnKey="*">
<Say>Please enter your pin number and then press star.</Say>
</Gather>
</Response>
如果您希望该信息到达您的服务器,您可以使用这样的操作:
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Gather action="/process_gather.aspx" method="GET">
<Say>
Please enter your age and press star on your keypad.
</Say>
</Gather>
<Say>We didn't receive any input. Goodbye!</Say>
</Response>
Twilio 然后将使用这些数字向您的服务器发出 POST 请求,您可以随心所欲地使用它。
例如,在 .NET MVC 中生成 TwiML 可以按如下方式完成:
public ActionResult MainMenu()
{
var response = new TwilioResponse();
response.BeginGather(new {
action = "/process_gather.aspx", numDigits = "2" });
response.Say("Please enter your age");
response.EndGather();
response.Hangup();
return TwiML(response);
}
此外,请查看此 blog post 以了解使用 Twilio 在 .NET 中的调用流程。
希望对你有帮助
我对 Twilio 比较陌生,虽然它看起来是一个很棒的应用程序!
基本上我需要完成的是:
我有一个 .net 应用程序,它可以生成拨出电话并提示对方输入数字 - 如何将该输入(当然只是数字)返回到我的 .aspx 页面以进一步处理它?例如,如果它说 "enter your age" 然后我希望 .aspx 页面在标签中显示他们的年龄。
我目前在页面上有一个按钮发送到运行 twiml 代码的 .ashx 文件,该文件以
结尾 context.Response.Write(twiml.ToString());
context.Response.End();`
类型是"text/xml"
也许我很愚蠢,完全没有抓住要点,但我一辈子都想不出如何做到这一点。
非常感谢您!
西德
这里是 Twilio 开发人员布道者。
您要查找的是 Gather 动词。有了它,您可以获得在通话中输入的数字。因此,当有来电时,您可以 return TwiML 这样:
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Gather timeout="10" finishOnKey="*">
<Say>Please enter your pin number and then press star.</Say>
</Gather>
</Response>
如果您希望该信息到达您的服务器,您可以使用这样的操作:
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Gather action="/process_gather.aspx" method="GET">
<Say>
Please enter your age and press star on your keypad.
</Say>
</Gather>
<Say>We didn't receive any input. Goodbye!</Say>
</Response>
Twilio 然后将使用这些数字向您的服务器发出 POST 请求,您可以随心所欲地使用它。
例如,在 .NET MVC 中生成 TwiML 可以按如下方式完成:
public ActionResult MainMenu()
{
var response = new TwilioResponse();
response.BeginGather(new {
action = "/process_gather.aspx", numDigits = "2" });
response.Say("Please enter your age");
response.EndGather();
response.Hangup();
return TwiML(response);
}
此外,请查看此 blog post 以了解使用 Twilio 在 .NET 中的调用流程。
希望对你有帮助