Facebook Messenger bot not sending messages in order

后端 未结 11 2090
遥遥无期
遥遥无期 2021-01-01 21:00

I\'m playing around with building a simple Facebook Messenger chatbot and I\'m having trouble sending messages in sequence.

In the example above, it should

11条回答
  •  醉酒成梦
    2021-01-01 21:30

    Instead of adding static timeouts, I would create a queue data structure. When the bot wants to send a message, append the contents to the end of the queue. On the message post callback, check if there are any messages still in the queue and call the function again using recursion and remove from the queue accordingly.

提交回复
热议问题