![](/img/trans.png)
[英]sending whatsapp message via twilio api successful but message not received
[英]Indicating a WhatsApp message is received, via the Twilio API, in NodeJS?
我们正在创建一项服务,该服务将通过 Twilio 服务接收 WhatsApp 消息。 这可行,但我们的问题是我们无法弄清楚如何告诉发件人我们的服务器已“读取”消息。 消息始终显示为“已发送”,从未“已读”,即使在回复消息后也是如此。 我们查看了文档,但似乎看不到如何执行此操作。
我们的服务器是用 NodeJS 编写的,并且在 HTTP 端使用 Express。
下面是我们正在使用的代码的等价物(不是运行示例):
import { twiml } from 'twilio';
const { MessagingResponse } = twiml;
async receiveMessage(req: Request, res: Response, next: NextFunction) {
const message = req.body;
// Send back an empty response, we will process asynchronously
const immediateResponse = new MessagingResponse();
res.setHeader('content-type', 'text/xml');
res.send(immediateResponse.toString());
// TODO indicate message as read
// Do what ever logic is needed for given message
const replyMessage = await processMessage(message);
const messageToTwilio = {
body: replyMessage,
from: message.To,
to: message.From
};
const twilioResponse = await this.client.messages.create(messageToTwilio);
// Record value of twilioResponse in DB
}
谁能建议我应该在 API 中使用什么?
我就这个问题联系了 Twilio,结果证明目前这是不可能的。 虽然他们认为这是一项有用的功能,但目前并不是实施的优先事项。
请注意,可以通过状态 Webhook 获取传出消息的传递状态,但无法向远程方指示传入消息已“读取”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.