简体   繁体   English

在 NodeJS 中指示通过 Twilio API 收到 WhatsApp 消息?

[英]Indicating a WhatsApp message is received, via the Twilio API, in NodeJS?

We are creating a service that will receive WhatsApp messages via the Twilio service.我们正在创建一项服务,该服务将通过 Twilio 服务接收 WhatsApp 消息。 This works, but our issue is that we can't work out how to tell the sender that our server has 'read' the message.这可行,但我们的问题是我们无法弄清楚如何告诉发件人我们的服务器已“读取”消息。 The messages always appear as being 'delivered' and never 'read', even after responding to the message.消息始终显示为“已发送”,从未“已读”,即使在回复消息后也是如此。 We have looked in the documentation , but can't seem to see how to do this.我们查看了文档,但似乎看不到如何执行此操作。

Our server is written in NodeJS and is using Express for HTTP side.我们的服务器是用 NodeJS 编写的,并且在 HTTP 端使用 Express。

Below is an equivalent of the code we are using (not a running example):下面是我们正在使用的代码的等价物(不是运行示例):

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
}

Can anyone suggest what in the API I should be using for this?谁能建议我应该在 API 中使用什么?

I contacted Twilio on this issue and it turns out this is not currently possible.我就这个问题联系了 Twilio,结果证明目前这是不可能的。 While they consider this a useful functionality, it is not currently a priority for implementation.虽然他们认为这是一项有用的功能,但目前并不是实施的优先事项。

Note, It is possible to get the delivery status of outgoing messages, via the status webhook, but it is not possible to indicate to the remote party that the incoming message was 'read'.请注意,可以通过状态 Webhook 获取传出消息的传递状态,但无法向远程方指示传入消息已“读取”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM