What are the cases in which Facebook Messenger Platform sends multiple events to a Webhook within one request? - facebook

On Facebook Messenger Developer docs, it is mentioned that:
Note that entry is an array and may contain multiple objects, so ensure your code iterates over it to process all events. For a complete description of event properties, see Webhooks Reference.
I've checked out most of the docs on various webhook events (e.g. messages etc), but they all seem to only have one object in the entry array.
In what cases does an entry array have multiple objects?

Related

REST API Designs with categories

Let's say there is a SINGLE mobile application which receives various types of notifications (like WhatsApp notifications, Facebook Messenger notifications ,etc). What would be a better REST API structure for this?
/users/test#abc.com/notifications //Gives all the notifications
There is a confusion between the below two formats on how .
/users/test#abc.com/notifications?category=whatsapp,facebook //Gives all the notifications
vs
/users/test#abc.com/notifications/whatsapp //Gives only whatsapp notification
/users/test#abc.com/notifications/facebook //Gives only facebook notification
To access an individual notification resource
/users/test#abc.com/notifications/facebook/{notification-id}
vs
/users/test#abc.com/notifications/{notification-id}
If a resource has a unique ID then it should be directly accessible from that, so in my opinion
/notifications/{id}
Would make most sense. In terms of filtering, this is probably more about preference than anything. Here's what I think would be the most idiomatic approach
/notifications // fetch all notifications
/notifications/facebook // fetch all Facebook messages
/notifications/whatsapp // fetch all WhatsApp messages
/users/{id}/notifications // fetch user notifications
/users/{id}/notifications/facebook // fetch user Facebook notifications
/users/{id}/notifications/whatsapp // fetch user WhatsApp messages
It really depends on how you define a notification resource and the relation with its category type (whatsapp, facebook...).
Non category dependent
If the structure of a notification is not dependent on its category, then you want to access it without any category context:
/users/test#abc.com/notifications/{notification-id}
And you can use the category as a filter to a collection of notifications:
/users/test#abc.com/notifications?category=whatsapp,facebook
category dependent
Otherwise, if a notification is structurally dependent on its category (e.g., if you want to define different actions when you deal with whatsapp notifications than when you deal with facebook notifications), then you might want to distinguish a notification according to its category:
/users/test#abc.com/notifications/whatsapp/{whatsapp-notification-id}
/users/test#abc.com/notifications/facebook/{facebook-notification-id}
In this case, you could have:
/users/test#abc.com/notifications/whatsapp/1
/users/test#abc.com/notifications/facebook/1
That define 2 different notifications (although it uses the same identifier).
Now requesting a collection of this kind of notifications is a bit different than the previous "non category dependent" case.
If you only want to have whatsapp notifications then simply call the category resource does the job:
/users/test#abc.com/notifications/whatsapp
But if you want to search on different categories, then you cannot apply your request to a specific category resource. Indeed, it makes no sense to ask for facebook notifications when you deal with whatsapp ones:
/users/test#abc.com/notifications/whatsapp?category=facebook # weird
One solution would be to make as many requests as there are categories requested:
/users/test#abc.com/notifications/whatsapp
/users/test#abc.com/notifications/facebook
But you will have to merge your results later.
Another solution would be to apply your query directly from
/users/test#abc.com/notifications?category=whatsapp,facebook
But the result will be different than the "non category dependent" case. Indeed, you won't be able to directly have your list of notifications, but a list of categories to access to your list of notifications.

facebook messenger an array of generic templates

I have noticed we have quick_reply and to send multiple of them, you can use quick_replies. https://developers.facebook.com/docs/messenger-platform/send-api-reference/quick-replies#quick_reply
How do I send multiple generic template attachments in one message. This is to enable a user scroll through and choose one of the templates.
I have seen one implemented by the Guardian bot. https://www.messenger.com/t/10513336322
You attach an array of elements as seen here: https://developers.facebook.com/docs/messenger-platform/send-api-reference/generic-template

How can I trigger custom emails to be sent in wordpress?

My goal is to use a user's answers to a few questions to trigger custom emails being sent to them with filtered content on my wordpress website. It seems like this is a common need, but can't find anything that allows it, or even is the right base to build a custom solution.
There are 3 main features I'm needing to do: First, the signup form lets users choose a few criteria via selection boxes.
Next, the captured information triggers an email being sent that matches the content they chose. For example, if the user says they're interested in waterskiing, the email that is auto sent would show the most recent posts in the water-skiing category.
Finally, the user responses would need to be saved to trigger actions at a later time if the content is not available yet. So for example, if they are interested in bowling, but there are no entries on bowling, nothing happens. However, once a post gets entered in this category, they are automatically emailed with that recent entry.
Any clarity you can provide here on plugins, software, etc that would lend to this functionality is much appreciated!!

Facebook Graph API Data Incorrect

Small problem here. I have an event created on Facebook and am using the Graph API to get the number of attendees.
I get the list of attendees with PHP from https://graph.facebook.com/EVENTID/attending?access_token=TOKENHERE and it returns a list of names.
However, the number of attendees is about 6 people lower than what is shown on the Facebook event page. Why would these numbers not match? Is there something in particular I'm supposed to do in the code to get the entire list?
As answered in the comments:
This discrepancy is probably down to a number of the attendees having opted out of Facebook Platform, which means their data isn't passed to apps via the API. Can't be 100% sure without the Event ID, but its a likely reason. – Simon Cross
From the Graph API, the people who have not joined the event will not show up under /{eventid}/attending, you need to add in the users who are returned in /{eventid}/not_replied. The not_replied set seems to be a special set in the GraphAPI.. and if you look at the docs, there is a mention of only people who have joined the event.

Multiple request ids

In the request 2.0 documentation, they mention that the app can get request_ids, which is a comma delimited list of Request IDs that a user is trying to act upon.
I was wondering if someone can give an example when multiple ids will arrive. Usually for each request the user sees a single notification so how come several requests might be combined to a single call?
All request are grouped in left pane, showing the number of them next to app name, aren't they? It seems only logical that you get them all if you click on the app name there.