在Django视图中等待Webhook或超时
我正在使用WhatsApp官方API向客户发送消息。如果他们在一定时间段内没有回复(或多或少),我想给他们发送提醒消息。换句话说,我将发送一条消息,并等待一段时间以进行响应。如果他们响应,则不需要提醒消息。如果他们不这样做,我将向他们发送提醒消息。 WhatsApp API回复时会发送Webhook通知。
如何在Django视图中实现?我正在考虑每次等待时都会创建异步过程/线程,并以某种方式处理该过程中的超时条件。这是正确的方法吗?我认为,就使用的服务器时间而言,这将是昂贵的,但我不确定。如果这是正确的方法,请显示一些有关如何完成的伪代码。
我将在Heroku上部署我的应用程序。
您的答案非常感谢。
I am using WhatsApp official API to send messages to customers. I want to send them a reminder message if they have not replied during a certain period of time (a couple of hours more or less). In other words, I will send a message and wait for a certain period of time for their response. If they respond, no reminder message is needed. If they don't, I will send them a reminder message. WhatsApp API sends webhook notifications when they reply.
How do I implement that in a Django view? I am thinking of creating an async process/thread each time I want to wait, and handle the timeout condition in that process somehow. Is this the right approach? I think that would be costly in terms of server time used, but I am not sure. If this is the right approach, please show some pseudo-code on how it can be done.
I will be deploying my app on Heroku.
Your answer is much appreciated..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论