如何在Node.js中获取Twilio SMS正文文本 [英] How to get a Twilio SMS body text in Node.js

查看:96
本文介绍了如何在Node.js中获取Twilio SMS正文文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究与Twilio集成的我的附带项目.这是在Hapi.js框架上运行的Node.js应用.

I'm working on a side-project of mine which integrates with Twilio. It's a Node.js app running on the Hapi.js framework.

我已使用Twilio设置了应用程序,以便在给Twilio号码发短信时,Twilio会从我的应用程序的路由中获取请求,并在响应中以静态消息发回给我.

I have the app set up with Twilio so that when I text my Twilio number, Twilio gets the request from my app's route and texts me back with a static message in the response.

我遇到的麻烦是从用户的文本中获取SMS正文.假设我用类似banana这样的词给Twilio数字发短信,我希望能够从请求中检索该数字,以便可以基于它获得动态消息.

What I'm having trouble with is getting the SMS body from the user's text. Let's say that I text the Twilio number with a word like banana I want to be able to retrieve that from the request so that I can have a dynamic message based on it.

除其他外,我已经尝试过request.Bodyrequest.message,但似乎无法将用户的文本检索到Twilio号.我浏览了Twilio的文档,似乎无法弄清楚.我看到了此PHP关键字关于Twilio的教程看起来很有希望,但是像访问该教程中的request.Body一样似乎根本不起作用.

I've tried request.Body, request.message, among several other things, and I can't seem to retrieve the user's text to the Twilio number. I've looked through Twilio's documentation and can't seem to figure it out. I saw this PHP keyword tutorial on Twilio which looked promising, but even accessing request.Body as in that tutorial doesn't seem to work at all.

有人知道如何从用户发送的Twilio SMS中获取文本正文吗?感谢所有帮助

Does anyone know how to get the text body from a Twilio SMS that a user sends? Any and all help is appreciated

推荐答案

尝试了多种方法从Twilio检索请求有效载荷后,我发现Twilio请求正文可以通过request.url.query访问,因此,,可以通过request.url.query.Body检索.感谢@MattHarrison的帮助!

After trying different methods to retrieve the request payload from Twilio, I found that the Twilio request body can be accessed via request.url.query, and therefore, the Body of the text, can be retrieved via request.url.query.Body. Thanks for the help @MattHarrison!

这篇关于如何在Node.js中获取Twilio SMS正文文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆