0

I've inherited a Facebook webhook application written in Node that tracks posts for several Facebook pages associated with our organization. On 2017-07-02 (about 3 weeks ago), it appears Facebook stopped pushing webhook updates to this application. This application had been running successfully for the last couple years prior to this.

These are the last entries I see in our application's access log:

724661:173.252.105.118 - - [02/Jul/2017:16:40:23 -0700] "POST /callback/facebook HTTP/1.1" 200 5 "-" "Webhooks/1.0"
724662:66.220.145.151 - - [02/Jul/2017:16:55:29 -0700] "POST /callback/facebook HTTP/1.1" 200 5 "-" "Webhooks/1.0"
724663:31.13.114.11 - - [02/Jul/2017:16:55:30 -0700] "POST /callback/facebook HTTP/1.1" 200 5 "-" "Webhooks/1.0"

I have confirmed that our application is still functioning by sending a manual request using curl that it did successfully process.

I see here that Facebook marked availability of v2.3 of their API to end on July 8:

In the upgrade guide for v2.3 to v2.4, it notes:

There are a number of Page permissions changes between v2.3 and v2.4 that your apps will need to account for. Notably, a Page access token is now required to interface with /v2.4/{page_id}/promotable_posts, /v2.4/{page_id}/offers, and /v2.4/{page_id}/milestones.

Is this why Facebook has stopped pushing updates to our webhook endpoint? If so, where can I find more information on using Page access tokens with webhooks?

Chapman Atwell
  • 1,007
  • 1
  • 9
  • 13
  • 1
    No, the mentioned changes have nothing to do with this. Facebook will stop sending updates to your app after a while, if your app is not responding with a 200 status code quickly enough. In such a case, you have to set up your callback URL again. – CBroe Jul 28 '17 at 08:46
  • @CBroe Thanks for the response. Is this based on your experience running a webhook or is this documented somewhere? – Chapman Atwell Jul 28 '17 at 14:32
  • 1
    https://developers.facebook.com/docs/messenger-platform/webhook-reference#response – CBroe Jul 28 '17 at 16:50
  • Thanks again. Curiously, I didn't get an alert regarding slow response in the dev dashboard. But the key lesson is our app needs to be more resilient in dealing with these kind of contingencies. If you want to combine your comments into an answer, I'll select it as correct answer. – Chapman Atwell Jul 28 '17 at 17:16

1 Answers1

2

Facebook will stop sending updates to your webhook callback URL after a while, if your app is not responding with a 200 status code quickly enough. In such a case, you have to set up your callback URL again.

This is - somewhat - documented under https://developers.facebook.com/docs/messenger-platform/webhook-reference#response,

Your webhook callback should always return a 200 OK HTTP response when invoked by Facebook. Failing to do so may cause your webhook to be unsubscribed by the Messenger Platform.

It is extremely important to return a 200 OK HTTP as fast as possible. Facebook will wait for a 200 before sending you the next message. In high volume bots, a delay in returning a 200 can cause significant delays in Facebook delivering messages to your webhook.

It does not explicitly mention this here, but I am pretty sure failing to respond with a 200 in a certain amount of time is also considered a failure.

Even less real-time related tools such as the Facebook Scraper (that grabs the Open Graph meta data from links shared by users) have a timeout of 10 seconds; so Facebook's patience for webhooks is not gonna be any longer, likely rather (much) shorter specifically for Messenger platform related webhooks - those response times directly influence the user experience after all.


Edit: You realized you actually asked about Graph API webhooks, not Messenger platform. But it is similar for those - https://developers.facebook.com/docs/graph-api/webhooks#callback

If any update sent to your server fails, we will retry immediately, then try a few more times with decreasing frequency over the next 24 hours. Your server should handle deduplication in these cases. Updates unaccepted for 24 hours will be dropped.

Response
Your endpoint should return a 200 OK HTTPS response for all update notifications.

And from discussions in the FB developers group I know that repeated timeouts also cause un-subscription from the webhooks in this case.

Community
  • 1
  • 1
CBroe
  • 91,630
  • 14
  • 92
  • 150
  • One additional note that seems relevant here: the FB documentation above refers to [Messenger Platform Webhook](https://developers.facebook.com/docs/messenger-platform/webhook-reference) documentation whereas my app uses [Graph API Webhooks](https://developers.facebook.com/docs/graph-api/webhooks). That may explain why I didn't see any alerts like the ones in the documentation. It may also explain why when I tried to run the validation test on that page, it failed. – Chapman Atwell Jul 28 '17 at 18:53
  • Yeah, I just saw your comment above under the question mention that, so I edited the answer to reflect this. Facebook pretty much treats Messenger and Graph API Webhooks the same in that regard. The timeouts might be a bit more generous for the latter, I would assume - but not that much either way. – CBroe Jul 28 '17 at 18:57