Facebook Webhooks Mentions Event json does not include sender fb user id and user name - facebook

This is the sample response json which that Facebook sends to the server once some user mentions page in his post (This json is mentioned as the sample json by facebook):
{
"field": "mention",
"value": {
"post_id": "44444444_444444444",
"sender_name": "Example Name",
"item": "post",
"sender_id": "44444444",
"verb": "add"
}
}
However the json which I am receiving does not contain sender name and sender id :
{
"entry": [
{
"id": {page_id},
"time":{timestamp},
"changes": [
{
"field": "mention",
"value": {
"item": "post",
"verb": "add",
"message": "{message}",
"post_id": "44444444_444444444",
"created_time": {timestamp}
}
}
]
}
],
"object": "page"
}
Can anyone tell me , why Facebook is not sending sender name and sender id .
I am using FB API version :3.2
Permissions are manage_pages, publish_pages

Related

Unsupported get request. Object with ID '{USER_ID}' does not exist, cannot be loaded due to missing permissions, or does not support this operation

I am getting this from Facebook webhook. I am trying to get the sender's name and profile picture.
<pre>
{
"object": "page",
"entry": [
{
"id": "172916740162087",
"time": 1609667491,
"changes": [
{
"value": {
"from": {
"id": "2529118547136023",
"name": "Md Abid Hasan Nayem"
},
"post": {
"status_type": "added_photos",
"is_published": true,
"updated_time": "2021-01-03T09:51:29+0000",
"permalink_url": "https://www.facebook.com/CodeWareLTD/posts/851154192338335",
"promotion_status": "inactive",
"id": "172916740162087_851154192338335"
},
"message": "Happy new year",
"post_id": "172916740162087_851154192338335",
"comment_id": "851154192338335_853191445467943",
"created_time": 1609667489,
"item": "comment",
"parent_id": "172916740162087_851154192338335",
"verb": "add"
},
"field": "feed"
}
]
}
]
}
</pre>
When I am sending request with the user id /{USER_ID}?access_token=token then it's returning this error.
Whereas I have all the required permissions approved.
<pre>
{
"error": {
"message": "(#3) Application does not have the capability to make this API call.",
"type": "OAuthException",
"code": 3,
"fbtrace_id": "ABtpgYvcMuaA_jQcW8Fdi3M"
}
}
</pre>
I opened a bug report, but they told me it's ok as per the current Facebook system design. But
still, I'm unable to get the user's first name, last name, and profile picture.
Bug Report Link: https://developers.facebook.com/support/bugs/887826828623849/.
Please, help me to get the exact API to get the sender's name & profile picture.
my currently successfully reviewed permissions are:
email,
pages_manage_metadata,
pages_read_engagement,
pages_show_list,
pages_messaging,
pages_read_user_content,
public_profile,
pages_manage_engagement,
pages_manage_posts

Why I do not receive the attachments in the Facebook Messenger webhook request?

Since yesterday (29/10/2020) i'm having this problem only on one of the pages linked to my app, the others work correctly:
The attached messages that the webhook receives from Facebook do not contain the attachment field.
Only messages with stickers contain the "attachment" field. All others (image, video, audio etc.) No.
What I expect (as facebook documentation) is:
{
"id": "682498302938465",
"time": 1518479195594,
"messaging": [
{
"sender": {
"id": "<PSID>"
},
"recipient": {
"id": "<PAGE_ID>"
},
"timestamp": 1518479195308,
"message": {
"mid": "mid.$cAAJdkrCd2ORnva8ErFhjGm0X_Q_c",
"attachments": [
{
"type": "<image|video|audio|file>",
"payload": {
"url": "<ATTACHMENT_URL>"
}
}
]
}
}
]
}
but I only receive:
{
"object": "page",
"entry": [
{
"id": "119320008135788",
"time": 1604051633128,
"messaging": [
{
"sender": {
"id": "XXXXXX"
},
"recipient": {
"id": "XXXXXX"
},
"timestamp": 1604051632953,
"message": {
"mid": "m_7DRP...."
}
}
]
}
]
}
This only happens on one page from 29/10/2020
Does anyone have the same problem / know why it happens?
The Facebook support team has confirmed my problem, and is investigating.
I am now solving using the graph api to get the desired message information using the mid
GET /v8.0/{message-id} HTTP/1.1
Host: graph.facebook.com
https://developers.facebook.com/docs/graph-api/reference/v8.0/message
Ex.
GET
https://graph.facebook.com/v8.0/' + mid + '?fields=message%2Cfrom%2Csticker%2Ctags%2Cid%2Cattachments.limit(10)%7Bid%2Cimage_data%2Cmime_type%2Cname%2Cfile_url%2Cvideo_data%7D&access_token=XXXXXX

Facebook webhook not triggered for feed updates

I subscribed my app to the feed event. I can check the subscribtion using
GET /{{app_id}}/subscriptions?access_token={{app_access_token}}
which returns
{
"data": [
{
"object": "page",
"callback_url": "https://f0e769f1.ngrok.io/api/facebook/webhook",
"active": true,
"fields": [
{
"name": "messages",
"version": "v3.0"
},
{
"name": "feed",
"version": "v3.0"
}
]
}
]
}
I check that my test page is subscribed with
GET /{{test_page_id}}/subscribed_apps?access_token={{test_page_access_token}}
and it returns:
{
"data": [
{
"link": "https://localhost:3000/",
"name": "xxxxxxx",
"id": "xxxxxxxx"
}
]
}
`
However, I don't receive any updates on my callback url when a subscribed page changes. I tried
Creating a new post
Commenting on an existing post
Liking a post
The messages event works fine. My app is still in development.

Sending a button response to fb messenger via api.ai

I have started playing with diaglofFlow a.k.a api.ai with fb messenger integration.
I defined an intent which current returns 3 responses. 2 text responses and 1 custom payload.
the 2 text responses comes just fine but the custom payload which is suppose to return a button is not.
the custom payload looks like
{
"recipient": {
"id": "1234"
},
"message": {
"attachment": {
"type": "template",
"payload": {
"template_type": "button",
"text": "What do you want to do next?",
"buttons": [
{
"type": "web_url",
"url": "https://www.messenger.com",
"title": "Visit Messenger"
}
]
}
}
}
}
Also, please note that the recipient id is something i am not sure how it should be provided. the fb documentation says it should be number of the recipient. I do not know how i am going to get that?
actually this works
{
"facebook": {
"attachment": {
"type": "template",
"payload": {
"template_type": "button",
"text": "What do you want to do next?",
"buttons": [
{
"type": "web_url",
"url": "https://www.messenger.com",
"title": "Visit Messenger"
}
]
}
}
}
}
recipient.id is the user's Page-scoped ID. You receive it in the sender.id prop of webhook events when the user initiates a conversation.
https://developers.facebook.com/docs/messenger-platform/introduction/integration-components#psid

page-id/notifications returns an empty array

I'm writing a desktop application using Facebook SDK .NET. This app must do somethink for every post, comment or message sent to a Facebook page. I'm using the page-id/notifications API command:
page-id/notifications?fields=id,title,unread,application,from,message,object&limit=250
This command returns correct unseen count in summary section but data array is empty:
{
"data": [
],
"summary": {
"unseen_count": 2,
"updated_time": "2016-02-05T14:53:10+0000"
}
}
If someone write a new wall post on the page or send a private message to the page, unseen_count is updated but data array is always empty. If someoune write a comment to an exisiting wall post unseen_count is updates and data array is populated with a comment notification (only this type of notification are added to data array):
{
"data": [
{
"id": "notif_XXXXXXXXXXXXXXX_XXXXXXXXXXXXXXXX",
"title": "yyyyy yyyyyyy commented on his post.",
"unread": 1,
"application": {
"link": "https://www.facebook.com/games/?app_id=xxxxxxxxxxx",
"name": "Feed Comments",
"id": "1967xxxxxxx"
},
"from": {
"name": "Mxxxx Sxxxxxx",
"id": "1020xxxxxxxxxxxxx"
},
"object": {
"created_time": "2016-02-05T14:52:32+0000",
"message": "ABCDEFGHILMNOPQRSTUVZ",
"id": "36xxxxxxxxxxxx0_546xxxxxxxxxxx0"
},
"to": {
"name": "Ixxxxxxx",
"id": "36xxxxxxxxxxxxx"
}
}
],
"paging": {
"previous": "xxxxxxxxxxxxxxxxxxxxxxxxxx",
"next": "xxxxxxxxxxxxxxxxxxxx
},
"summary": {
"unseen_count": 3,
"updated_time": "2016-02-05T14:55:23+0000"
}
}
Is it an API bug or there is something wrong in my API request?
I CANNOT use real time notification.
Thanks
Marco