I have followed the steps to setup the Facebook Messenger platform. The verification GET web hook request work perfectly, as does the subscribe but when I submit the chat I keep getting the follow Developer Alert:
Hi Norah,
We've noticed that your Webhooks subscription for callback URL https://{domain}/v1/webhook has not been accepting updates for at least 16 minutes. Please verify that your callback server is functioning so you may continue to receive updates. If you need to update your callback URL, see https://developers.facebook.com/docs/messenger-platform/webhook-reference#webhook_setup
If your callback URL continues to fail to accept updates for 8 hours straight, we will disable your subscription. To reactivate the subscription, make a POST request with the same parameters, and it will be reactivated.
My post request works through POSTMAN.
Please can someone help me! This is driving me nuts!
Do you have logs on your server for that post requests?
Facebook requires you to return status code 200 for the post request, so they know that you successfully received it. When they havent, they try it again and if that still fails after several times, they will give you this alert.
Maybe facebook uses another content-type or message content than you used with postman.
Your server logs should give you more insights about that.
Depending on what Webhook events that you have subscribed for a page, there will be callbacks for those events, and more, on the url you have specified in the Web Hook set up.
If you had subscribed to the message_deliveries event, every time a message is sent, whether from a user to your page or from your page to a user, there is a, maybe more, calllback with a Message Delivered json object. The Webhook Reference has an example of the Message Delivered json object, but no specification or explanation on what the fields mean.
Occasionally I find that an undocumented Read callback is received, sometimes. The undocumented json data for this is like:
{"object":"page",
"entry":[
{
"id":"1722858134648129",
"time":1465407550812,
"messaging":[
{
"sender":{"id":"1131485883560113"},
"recipient":{"id":"1722858134642218"},
"timestamp":1465407550868,
"read":
{
"watermark":1465407548057,
"seq":428
}}]}]}
Essentially, you must code your callback to handle ALL types of json data gracefully, including unknowns, even though you may not be ready to process them further. For those that you are not ready to handle or uninterested in, return nothing with Http status code 204 (in fact every callback should return 204 as the type is void).
If you handle only those types of json data you are interested in, any unexpected json data will most likely raise an exception in whatever language your web callback code is written in and result in a 500 server error returned to Facebook. It is this 500 error that is causing Facebook to make that complaint in your question.
Related
I'm currently developing my fist bot.
When I add a breakpoint somewhere in the code of my bot application, send a message from my Facebook page, and debugger stops at that point, after some seconds the debugger stops at that point again, making the debug procedure very complicated.
I understand this happens since I didn't acknowledge the message was received by returning a status code 200, and for that reason my Facebook Messenger application keeps sending the same request.
Is there a way to set up my Facebook Messenger application so that it only calls my webhook once, or to increase the period of time my webhook is called?
Otherwise, are there any suggestions overcome this?
Only option really is to send the 200 as soon as the webhook receives a message while you are debugging, so that you can step through any of your message processing.
I'm working on building an app that (among other things) uses the Facebook Graph API for Pages to reply to direct messages to a page. I send a POST request to /CONVERSATION_ID/messages as per the documentation, and everything seems to be working well.
The problem I'm encountering is that the documentation claims
"Also, a page can respond not more than twice to a user's message before the user has replied back,"
but I'm not seeing this happen during my testing.
https://developers.facebook.com/docs/reference/api/page/#conversations
I've so far sent 4 responses to the message initiated by the Facebook user that I am using to test my app with, and the Graph API has not yet given me an error message. The documentation also does not say what error message is supposed to be returned if a page attempts to send more than 2 responses to a message before the user replies back.
Does anyone know what the error message is that the Graph API returns when a page attempts to send more than 2 responses to a message?
I seem to have found the answer to my own question. While I could not find official documentation for the error messages, I found unofficial documentation for them at:
http://fbdevwiki.com/wiki/Error_codes
The error code I was looking for was there:
User has sent too many messages
With the Graph API, I publish a story by POSTing to the /me/feed connection. I get back a success or an error result from Facebook. So far so good. Once in a while, the API takes a long time and the connection times out. In that case, I don't know for sure if the request succeeded of failed (i.e. maybe the request never reached Facebook, or maybe it succeeded and the result never made it back to me). How do you handle this situation?
More details:
I publish a lot of posts to Facebook and Twitter, so the timeout situation happens often. With Twitter, the solution is easy. If the request times out the first time, I simply try again. Twitter detects duplicates, so if the post was successfully published the first time, then I'll get a "duplicate status" error on the second request and I know that I don't need to retry any more.
But Facebook doesn't detect duplicates, so if I retry the publish request, I risk having two copies of the post published to the user wall, which is not nice. On the other hand, if I don't retry, I risk having the post not published at all. Thoughts?
I get back a success or an error result from Facebook.
Hmmm. When I post to the Graph API, I get back an error or the id of the post. I never see any success message. What SDK are you using around the API?
Once in a while, the API takes a long time and the connection times
out.
Usually when things are running slowly, it's due to the channelUrl not being specified. See https://developers.facebook.com/docs/reference/javascript/
It is important for the channel file to be cached for as long as
possible. When serving this file, you must send valid Expires headers
with a long expiration period. This will ensure the channel file is
cached by the browser which is important for a smooth user experience.
Without proper caching, cross domain communication will become very
slow and users will suffer a severely degraded experience.
Ok .. I am using the Dialog JS API to send requests to people. I know this is working because
The JavaScript callback shows the request ID
On the recipient's account, the "App Requests" item on the left side bar has a count which is increasing with each and every request that gets sent
What I cannot figure out is why, although the requests are being sent and the counts are increasing, there is nothing that indicates that a request has in fact been sent.
I have checked the Notifications section and it is empty. I have also checked the following two URLs, both showing nothing:
http://www.facebook.com/reqs.php
http://www.facebook.com/reqs.php#!/?sk=apps
After hours of debugging and looking at other peoples apps, I started digging into Facebook's bug tracker and found someone else with the same problem today Apparently there are a number of "request" bugs today.
https://developers.facebook.com/bugs/237217296327314
Do you have a valid canvas url and valid secure canvas url in your facebook app settings? May be something to check as I believe it is required.
Notification when the user first login, not so hard, just require a database scan, I can deal with that. However, when a friend send a request or comment on profile X, a notification is sent, and almost immediately receive on the other end even when the user X not making any request. Is it polling? Does not feel like it, since the page never refresh itself. It must be something else? Anyone have any idea? maybe Web Push?
Facebook uses long-polling.
While you're on their page, they have a script continually issue requests to a particular URL. Instead of immediately responding, the server handling that URL first waits for a message to come in to its queue, and then sends that message out to the user. If a certain timeout is reached, the server responds without sending a message, and the client-side script makes another request to that URL.
To see this in action, open up Firebug's Net tab while on a Facebook page and wait for a couple minutes. You should see requests that last for a minute and then are followed up with a new request.
I believe they use AJAX/Javascript for that. It would allow the page to get information from the server and display it without reloading the page. You should be able to do this with an AJAX library like JQuery or something similar. As for whether or not Facebook itself does push or poll, I have no idea, but you can get a similar behavior by polling with AJAX.