在Django视图中等待Webhook或超时

发布于 2025-02-11 15:36:14 字数 331 浏览 2 评论 0原文

我正在使用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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文