Facebook API Instagram webhook not firing - facebook-graph-api

I am having trouble testing Facebook API's Instagram webhooks
Here is what I've done :
My Facebook application is validated with manage_pages, instagram_manage_insights and instagram_basic permissions
My Facebook application is "Live"
I have subscribed my app to my Facebook page POSTing on subscribed_apps endpoint (explained here: https://developers.facebook.com/docs/instagram-api/guides/webhooks/#install-app ). I already use the "feed" field. GETing subscribed_apps endpoint give the following result:
# v6.0/{my-page-id}/subscribed_apps?fields=subscribed_fields
{
"data": [
{
"id": "{my-app-id}",
"subscribed_fields": [
"feed" // the missing "instagram" here seems normal as it is not handled by API
]
}
]
}
Using ngrok I am trying to test the webhook on my local machine. I correctly receive the "test" data (using app dashboard button) but nothing happen when I subscribe to the webhook
I don't understand what I am missing here. The feed webhook I also subscribed too, works perfectly.
UPDATE
I managed to recieve the "story_insights" hooks, so I guess my configuration is OK. But I still don’t get any incoming comment or mention. Are thesi features still available in new graph api versions ?

Related

How to get the user's information who mentioned a page on Facebook?

I have successfully setup a Facebook App which provides Business Page management.
The goal is to get notified when a Facebook user mentions the said Page and identify who.
Setting up the webhook, for every mention I receive this kind of payload:
{
"entry":[
{
"id":"105569338984024",
"time":1673197963,
"changes":[
{
"value":{
"message":"BusinessPage I mention you",
"post_id":"5882266138421716_3303976449916555",
"created_time":1673137958,
"item":"post",
"verb":"add"
},
"field":"mention"
}
]
}
],
"object":"page"
}
Contrary to messaging or comments, I do not receive any information about the user who created this mention.
How should I get the user info? Or perhaps I did not setup the webhook properly?

How do I get instagram_basic permission during development?

I'm trying to use this endpoint from the Instagram graph api:
GET /ig_hashtag_search?user_id={user-id}&q={q}
Documentation for this endpoint can be found here.
I'm running this GET request:
https://graph.facebook.com/v14.0/ig_hashtag_search?q=coke&transport=cors&user_id=<my_user_id>&access_token=<my_access_token>&q=coke
and get this as response:
{
"error": {
"message": "(#200) Requires instagram_basic permission to manage the object",
"type": "OAuthException",
"code": 200,
}
}.
The user id comes from my instagram account and the access_token that I'm using is a User token generated with "Graph API explorer" and I can see that this token has the scope "instagram_basic" when using the "Access Token Debugger".
I can't understand why this does not work? Do I really need to submit a API review just to test the hashtag endpoint during development?
Please help!
I guess sometimes App review team of Facebook doesn't know what is the usage of the permission so they just decline the submissions randomly. I got that permission like 3 months ago and i checked my app review. I send them this text
We are going to use instagram_basic to read an Instagram account profile's info and media. We will get the basic metadata of an Instagram Business account profile like "USERNAME", "ID", "FOLLOWERS", "FOLLOWING". You can check the Screescast to see how we use the instagram_basic on our app.
Here is what they saw while they do the app review
Also be careful while you send requests, keep in mind to change it to development mode. Some of the endpoints works only in live mode. The API still changes a lot and there are tons of bugs i see in my project. I hope this helps.

Instagram Webhook subscription fails

I am trying to enable an Instagram story_insights webhook on a live Facebook App. I am able to receive test data successfully, but won't receive any live data.
The webhook has been configured via the Facebook App Dashboard for an app with both "manage_pages" and "instagram_manage_insights" permissions granted.
I tried to perform a POST request to the {page-id}/subscribed_apps endpoint but couldn't subscribe to the instagram story insights as there is no related subscribed_field.
Is registering the webhook in the app dashboard sufficient to receive data, or do I need to perform some kind of registration for each Facebook Page connected to an Instagram Business account?
https://developers.facebook.com/docs/instagram-api/guides/webhooks/
With Graph API version 3.2, the /{page-id}/subscribed_apps edge now requires the subscribed_fields parameter, which currently doesn't support Instgram webhooks fields. To get around this, use an older version of the API, or include the subscribed_fields parameter with a non-Instagram field, then unsubscribe from the field later using your app's dashboard.
Just use some field that will most likely not change from your Facebook Page, like "email".
From the API docs it says ( https://developers.facebook.com/docs/instagram-api/guides/webhooks )
Technically it doesn't matter which Page Field you subscribe to. Your app will not receive notifications of changes to that field unless you configure Page subscriptions in the App Dashboard and subscribe to that field.

AWS Lex and Facebook Messenger Integration Not Working

I'm banging my head against the wall trying to get an AWS Lex based chatbot integrated with Facebook.
As far as I can tell, everything is set up correctly.
When I send a message to my page in Facebook, I don't get a reply. However, the analytics in my app shows that the app is getting messages, so I know the message is making it from the page to the app.
When I try to hit the AWS Lex Webhook directly using POSTMAN, the webhook responds to literally everything I sent to it with a blank HTTP 200 OK response.
The lambda function that is tied to the AWS Lex chatbot is not getting invoked as a result of the messages from Facebook because no logs are getting generated and cloudwatch doesn't show an attempts to run the lambda function.
Does anyone have any ideas?
UPDATE : I ended up engineering around this by bypassing the Facebook channel capability inside AWS Lex and using Lambda instead. I deployed a passthrough API which calls a lambda function and then interacts with AWS Lex via Boto3/Python. In theory this is all supposed to be taken care of from inside AWS Lex with the Facebook channel integration, but I wasn't able to get it to work so I just built around it.
Verify Amazon lex is properly configured with facebook messenger .
Check : Page access token
Verification token
App ID
Check if your webhook is subscribed to page you are messaging on.
Check if your facebook user is added as tester/admin/developer
Check if your latest version of BOt is published on intended alias.
Also while configuring webhook tick necessary options : messages, messaging_postbacks, messaging_optins, message_deliveries, message_reads, messaging_payments
This should resolve your head ache. If not please reply

Getting notifications of managed page using Graph API

Is there any way to get notifications of a managed page just as it can be done for users?
For a user I'd trivially trigger a GET request to /me/notifications. I've tried doing the same for a managed page (using the access token provided by /me/accounts), that is triggering a GET to //notifications?access_token= but I get a "Unsupported get request" error message, which I guess means that the notifications connection is not available for pages.
Is there any way to get this via Graph? The web page has a notifications link/shortcut for each managed page.
Per the graph API Explorer, here are the connections you can access of the page, and unfortunately notifications is not currently on their list:
albums
events
feed
links
notes
photos
posts
questions
statuses
tagged
videos
However, you could try fql?q=
SELECT notification_id, sender_id, title_html, body_html, href
FROM notification
WHERE recipient_id=me()
EDIT
I used a valid PAGE access token and was able to get back data....
{
"data": [
{
"notification_id": "nnnnnnnnnnnn",
"sender_id": nnnnnnnnn,
"title_html": "xxxxxxx posted on Beer's timeline.",
"body_html": "",
"href": "http://www.facebook.com/permalink.php?story_fbid=nnnnnnn&id=nnnnnnnn"
}
]
}