node.js 中的 Twilio SMS 回复 [英] Twilio SMS reply in node.js

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

问题描述

我正在 node.js 中使用 twilio 编写移动通知系统,目前我能够向用户发送 SMS 消息.但我希望用户回复回复.我需要收集用户发送文本的电话号码以及消息的内容(以查询我的 mongoosedb)

I'm writing a mobile notification system using twilio in node.js and I am currently able to send SMS messages to users. But I would like users to reply back with a response. I would need to gather the phone number the user sent the text from as well as the contents of the message (to query my mongoosedb)

我找不到这方面的太多信息,因此非常感谢您的帮助.

I couldn't find much info on this so any help is appreciated.

推荐答案

Twilio 布道者在这里.

Twilio evangelist here.

查看此博客post 向您介绍了我们的 Node 助手.如果您向下滚动到标题为生成 TwiML 以处理入站呼叫和 SMS"的部分,它将引导您完成从 Twilio 接收 SMS 消息的过程.

Check out this blog post which introduces you to our Node helper. If you scroll down to the section titled "Generating TwiML to handle inbound calls and SMS", it will walk you through receiving an SMS message from Twilio.

基本思想是,当您的用户回复您的消息时,Twilio 将通过向您为 Twilio 电话号码配置的某个 URL 发出 HTTP 请求来告诉您.该 URL 是您在 Node 应用中创建的某个端点.

The basic idea is that when your user replies to your message, Twilio is going to tell you that by making an HTTP request to some URL that you have configured for your Twilio phone number. That URL is some endpoint that you have created in your Node app.

作为该请求的一部分,Twilio 将向您传递一些表单参数.在您打算使用传递到 POST 函数的请求对象来获取 Twilio 传递给您的参数时:

As part of that request, Twilio is going to pass some form parameters to you. In your going to use the request object that is passed into the POST function to get the parameters that Twilio passes you:

console.log(request.body.from);
console.log(request.body.to);

转到我们网站上的此页面以查看所有Twilio 将在我们发送给您的参数

Heave over to this page on our website to see all of the parameters Twilio will send you when we

希望有所帮助.

这篇关于node.js 中的 Twilio SMS 回复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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