Twilio SMS reply in node.js

こ雲淡風輕ζ 提交于 2019-12-13 14:38:12

问题


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.


回答1:


Twilio evangelist here.

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.

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.

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);

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

Hope that helps.



来源:https://stackoverflow.com/questions/20295725/twilio-sms-reply-in-node-js

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!