简体   繁体   English

SMS中的Twilio ..gather数据

[英]Twilio ..gather data in SMS

I have been working on Twilio for a while and very comfortable in gathering input from user during a phone call. 我在Twilio上工作了一段时间,很舒服地收集了电话中用户的输入。

However I am in need of implementing a feature to my application where in a customer can text the invoice Number and get back the status as text. 但是,我需要在我的应用程序中实现一项功能,使客户可以在其中以文本形式发送发票编号并以文本形式返回状态。

Here is the sample code for phone call 这是电话的示例代码

<Response>
    <Gather action="Admin/CheckInvoice">
        <Say>
           Please enter invoice number followed by #
        </Say>
    </Gather>
 </Response>

In the above code when the customer calls and enters the Invoice number followed by #, the action method (ASP.NET MVC) CheckInvoice gets triggered. 在上面的代码中,当客户致电并输入发票号后接#号时,将触发操作方法(ASP.NET MVC)CheckInvoice。

public ActionMethod CheckInvoice(string Digits)
{

}

How can I accomplish the same using SMS ?. 如何使用SMS来完成相同的工作?

Twilio evangelist here. Twilio的传播者在这里。

Twilio passes the parameters included in its webhook call to your URL as form encoded values. Twilio将其webhook调用中包含的参数作为表单编码值传递给您的URL。 Since it looks like you are using ASP.NET MVC, you can just use Model Binding to grab any of those values. 由于看起来您正在使用ASP.NET MVC,因此可以仅使用模型绑定来获取所有这些值。

For an incoming SMS messages, your Action method would look something like this: 对于传入的SMS消息,您的Action方法如下所示:

public ActionResult IncomingSms(string Body) {
    // Body id the name of the parameter that contains the SMS message
}

The list of the base set of parameters included in the Twilio Request is here: Twilio请求中包含的基本参数列表如下:

https://www.twilio.com/docs/api/twiml/sms/twilio_request https://www.twilio.com/docs/api/twiml/sms/twilio_request

Hope that helps. 希望能有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM