WhatsApp Business API Webhook Getting Triggered Automatically
I have a working WhatsApp Business API Project however I am facing a weird problem the Webhook URL that I provided in the Facebook Developers app is getting triggered automatically even without a message being sent.
Here is how is the flow of my Application:
1- The user sends the Message on WhatsApp Number 2- A Firebase Function is triggered which generates the reply 3- The user gets the reply back
This is working fine, however, if the user sends the message, it sends back the reply.
However, I see that the user is still able to get the reply back even without sending the message on the WhatsApp Business API Number.
During the development, I made a mistake when I deployed the code which had an error and maybe that is why it is in a loop to send back the same message.
Right now I am solving this problem by deleting the Facebook Developers App and recreating it again and changing the App Id, and Token again since I don't see any option to stop this.
I was returning the response 500 in the catch block which was causing this behavior. The Webhook must return a 200 response code even in case of a catch block.
It is mentioned in the official API documentation: