I keep getting double requests on to my webhook when trying to create a Facebook bot. I don't know why or how to stop this. My code seems standard.
I'm using the request module in Node.js to send responses.
Is this a known issue or is there a Node based way to mitigate this?
I've been seeing multiple deliveries on my bots for two reasons:
- FB seems to have a 15 second timeout on webhook requests. That is, if your webhook does not return a
200 - OK
within 15 seconds, FB will retry to request a second time.
- Like @iownthegame wrote, if you register for the
message_deliveries
event, FB will send you delivery receipts.
One way to handle duplicate deliveries is to keep track of the last seq
value that your bot saw. Obviously if you are load balancing webhooks requests across a pool of servers (eg on Heroku), you will have to share the last seen seq
value across all your instances.
Did you also register for the message_deliveries event for your webhook? If yes it will send you the message deliveries for confirmation.