When does Facebook Page Conversation webhook is triggered? - facebook

Does anyone know when Facebook triggers this webhook?
https://developers.facebook.com/docs/graph-api/webhooks/reference/page/#conversations
I suppose to get thread id from this webhook, but seem that it never triggered no matter how I change the conversation (e.g make new conversation, change flags,...)

Turned out that it takes quite long time before it starting to send conversation callback. It works OK now.

Related

Facebook bot not receiving messaging_game_plays webhook events even though webhook is subscribed to those events

I'm testing a facebook instant games app and want my bot to collect messaging_game_plays events to log user data at the end of a play session.
I've set up an app page, app, and uploaded a build that I have moved to the testing stage. I also have a bot with a public webhook that I have successfully verified. The webhook is currently subscribed to messaging_game_plays as well as messages. I have simple echo functionality built into the bot and can spin up the messenger app on my phone, message the page, and receive an echo perfectly.
The problem arises when I go to the games section of my messenger app, play the game, and then exit the game. I expect my bot to receive a messaging_game_plays event per https://developers.facebook.com/docs/messenger-platform/reference/webhook-events/messaging_game_plays/, but I don't receive any indication in the logs of the bot server that anything has called the webhook (even after waiting a significant amount of time).
So my question is/questions are: am I missing something that is required for the messaging_game_plays to be sent to my bot? Is there anything that I need to add to my app-build specifically for this event to trigger? Is launching the game on my phone and exiting the game sufficient for testing this event?
I've searched forums and documentation with no luck but maybe I've missed something along the way. I have checked this question: Facebook Messenger webhook setup, but not triggered, and that helped me successfully trigger messages events which I am getting, I just can't seem to collect messaging_game_plays events.
I am rather new to this process so I may be missing something small, any help would be greatly appreciated!
For reference:
app webhook subscriptions
What does your fbapp-config.json file say? If your bot opt-in parameter is 'opt_in_dev' or 'opt_in_public' you will need to call the subscribeBotAsync method to subscribe your user to the bot before any webhooks will be sent.
Messenger bots will need to be opt-in only from January 19th (see here: https://www.facebook.com/fbgaminghome/blog/important-game-bots-update).
We're making this change to ensure a better player experience.
If you want to transfer player data without requiring the bot to be opted-in, you can use standard JavaScript fetch/XMLHttpRequest with getSignedPlayerInfoAsync to avoid tampering.

Facebook Messenger Bot - How to disable bot and allow human to chat

so this is something I've been trying to think through for about 16 hours. I am coding with PHP / CuRl / etc - the bot works and everything is fine. My current issue is figuring out how to disable the bot and allow a human to begin chatting with the customer/sender.
Has anyone successfully, created a route for this ? I mean it's pretty hard from what I see, you'd have to disable etc etc. A lot of effort for my clients.
Thanks for any input.
Facebook has rolled out a "Handover Protocol" which is supposed to facilitate a combined human/bot Messenger implementation.
https://developers.facebook.com/docs/messenger-platform/handover-protocol
It is a little unclear what actually occurs in step 5:
Pass thread control: At some point in the conversation, a user may choose to do something like interact with a live agent. To handle this, pass thread control from the Primary Receiver to the Secondary Receiver. The Secondary Receiver will receive a messaging_handovers webhook event to notify it that is now controls the conversation.
This doesn't actually disable the bot (as the OP requested), and isn't in the control of the Page owner but rather of the user. It seems FB envisions the user typing something like 'I would like to chat with a human' triggering the bot to pass control...but it would be nice to let the page owner simply put the app in standby and handle the messages herself.
Once you recognize someone wants to speak to a human, set a flag that disables all actions of your bot to on.
Then, have your bot message you, or whoever will respond, that a user ID needs responding to. Have your bot continue to send all messages received from them back to you until you enable the bot again.
Create some sort of way for your bot to interact with you that allows you to send a message to a specific user, and a way to once again enable the bot interaction with the user.
Probably something like "sendMessage104012301230'Hi, sorry you couldn't find [etc]', and enableUser104012301230
There may be a better way, but those are some thoughts on how I'd do it
If you enable messages echo, whenever a human respond using the page, a echo post is sent, and inside entry->messaging->message there's no app_id.
You can use that information to disable bot replies for a certain period, or disable indefinitely until you enabled is with some admin command (that's how I'm doing)
I thought a solution could be to label the message as "unsolved". Another solution could be to have the bot mark the conversation as unread. Does anyone know if it is possibile to add a label to a conversation or mark as unread through API?

Facebook Leadgen does not send Webhook Request

I've an app which collects leads generated using Facebook Leadgen Ad.
I've a Webhook subscribed for that but for some reason it never sends any requests when leadgen form is filled.
Earlier it was working without any issues.
I noticed yesterday that I received request an hour after forms were filled whereas today I've not received any requests but I do see new leads in the CSV file I downloaded.
Will appreciate if somebody can point me to what can be going wrong here.
Thanks in advance!
Not sure if you have come across this but, there is a testing tool which you can use to submit test leads for a page and see if the lead is getting pushed to your app successfully or not -
https://developers.facebook.com/tools/lead-ads-testing?__mref=message_bubble
If you click on the Track Status button after creating test lead it tell you the status of the webhook ping for the submitted lead.

Facebook Graph API subscription to /pages/conversations does not update on outgoing messages

I'm working with Facebook pages and building an app that allows you to send/receive private messages for your page from an external app.
Everything works fine, I can import old messages, send new one. My issue comes from the real time update subscription.
As explained here and here, I have subscribed to the conversations field on the page object. I also set up my server to receive Facebook verification and the updates.
I do receive updates when someone sends a new message to my test page ( even if it's a bit slow ~30 sec delay ) but I never receive any updates when the page replies to a message.
Is there something else I need to subscribe to in order to receive these updates ? Do I need to look for another way to do it ? Or is it just not supported by Facebook real time API updates ?
Any help appreciated, let me know if you need more info and have a nice day.

Facebook notification system: Is it polling?

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.