I have a bot running well receiving messages through the Facebook message webhook event. Everything works well when the user sends messages through the messenger app.
But When a user replies to the page story, it generates an incoming message as if it was a standard one and it's not possible to handle this context which is completely different form a user initiated conversation.
Any idea how to receive to differentiate a "standard" message from a "reply to page story" one ? Thx
There is no way to differentiate between these two entry points/sources. Both will trigger a regular message event with no specific attributes added that would allow you to differentiate the source/entry point.
I would like to have a log chat on my own server by collecting them from the chat history between user and my Facebook page.
I found the document mention about message
Next after I can verify my token using ngrok get my server connected with Facebook. Then I am looking for message.
In my understanding I have to listen to my page event. But I could not found and row mentions about it.
I found message_sends in the User. But it is not what I want.
I think document might not get uptodate. In the picture it is 2 and now it is 3.
Obviously subscription to User and select message_sends is not a correct solution on my use case. My case is user send message to my page. And my page send webhook to my chatlog server. That's all.
Question:
How to connect message on my page to my webhook url?
I have to use messenger and then Subscribe To Events
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.
It seems like the only way to do apprequests from user to user is via a dialogue. It also seem like I would need to do a ajax post with the invite ids to my server to record them happening. It's a bit unreliable.
Is there a way where I can get a list of the requests without needing to do a post?
You can only list pending requests by calling /me/apprequests on the user. Any other requests that were processed, you need to save them at the initial point of the request.
I tried $facebook->api('/me/apprequests/'); and that was blank even with 2 outstanding requests sent to 2 different friends. Nothing shows on graph explorer either.
What I need is a way to get this information without knowing the request ID, because I need to add this information to my database after they send a user to user request, to prevent them from sending more than one request to a friend per day. I know other apps do this, but I guess they aren't using FB.ui and probably record that info while sending the request?
There is no way to get requests that user sent via apprequests connection of user object, only those user received.
You can read the apprequests sent to a user by your app by issuing an HTTP GET request to /USER_ID/apprequests with user access_token.
You should store information about requests sent by application on your end if you need that info.