I had the same problem with my test application. I'm still new to the Messenger API, and my solution may be naive.
Initially, the code looked like this:
if (text) { sendTextMessage(sender, 'Response 1'); } else { queryDB( sendTextMessage(sender, 'Response 2'); ) } res.sendStatus(200);
Which continued to send Response 1 forever. The correct code is:
if (text) { sendTextMessage(sender, 'Response 1'); res.sendStatus(200); } else { queryDB( sendTextMessage(sender, 'Response 2'); res.sendStatus(200); ) }
You must send Status always after sending the message.
source share