【发布时间】:2020-09-16 10:18:09
【问题描述】:
我需要在 nodejs 中创建 2 路 SMS API。我收到了来自 twilio 的消息,但是当我回复同一条消息时没有收到消息
回复.js
const http = require("http");
const express = require("express");
const MessagingResponse = require("twilio").twiml.MessagingResponse;
const app = express();
app.post("/sms", (req, res) => {
const twiml = new MessagingResponse();
console.log(req.body);
twiml.message("Thank you for calling!. We got your message, Thank You.");
res.writeHead(200, { "content-Type": "text/xml" });
res.end(twiml.toString());
});
http
.createServer(app)
.listen(3000, () => console.log("server is up and running on port 3000"));
我通过 ngrok http 3000 更新了 webhook 中 twilio 编号中的 url,以获取来自 ngrok 的消息。 每当我用来回复消息时,我都无法在 ngrok 中看到任何日志。 请帮助我。 印度原产地号码是否有任何限制。我以前用印度号码回复messgae。
【问题讨论】:
-
"I updated the url in twilio number in webhook"。检查该 url 并确保它包含/sms,而不仅仅是 ngrok 域。
标签: node.js twilio sms twilio-twiml inbound