Webhook for hosted event? - facebook-webhooks

I have a webhook subscribed to Page feed events.
I want it to tell me when a public event has been created on the page OR a page the user manages.
The app dashboard tells me this is the JSON object that will get sent to me:
{
"field": "feed",
"value": {
"item": "status",
"post_id": "44444444_444444444",
"verb": "add",
"published": 1,
"created_time": 1536110879,
"message": "Example post content.",
"from": {
"name": "Test Page",
"id": "1067280970047460"
}
}
}
Is the event id delivered in the post_id field?
If not, how is it passed to me?
How can I test this further?
Is my only choice to create events by hand, record the event id and fill it in as the returned post_id?
Can this webhook receive notification from multiple user's pages?
If so, how do I configure it to do so?
If not, how do I do something like that? Do I need multiple webhooks?

As per relevant webhooks doc reference https://developers.facebook.com/docs/graph-api/webhooks/reference/page/#feed
event_id is not delivered in the post_id.
event_id is passed inside value as event_id, you may need to check you app, seems like event_id is being filtered out in the response.
Testing it further is a broad query, although you could use curl to perform testing with the configured FB account.
In a more generic context, the above webhook response can be used to autogenerate/handle the post, that is the core purpose of the existence of the webhooks(to trigger and automate events as and when occurred).
No, this webhook is page specific.
You need to configure the webhook for each page separately. (Find the page_ids that can be used to work with other pages corresponding to the user)
The same webhook shall work, although the only difference shall be the page parameter, so you would have to configure another set of webhooks for each page, with a unique page_id related to that user account.
Note: Refer to https://developers.facebook.com/docs/graph-api/webhooks/getting-started for testing the webhooks.

Related

Twilio WhatsApp username

I use Twilio [currently sandbox] for WhatsApp API.
I post to webhook when message is arrive to sandbox, I get data like this:
{"SmsMessageSid":"xxxxxxxxxx","NumMedia":"0","SmsSid":"xxxxxxxxxx","SmsStatus":"received","Body":"try1","To":"whatsapp:+14xxxxxxxxxx","NumSegments":"1","MessageSid":"xxxxxxxxxx","AccountSid":"xxxxxxxxxx","From":"whatsapp:+97xxxxxxxxxx","ApiVersion":"2010-04-01"}
Is there a way to get the username?
WhatsApp Facebook API does have a name in the payload:
{
"contacts": [ {
"profile": {
"name": "Kerry Fisher"
},
"wa_id": "16315551234"
} ],
"messages":[{
"from": "16315551234",
"id": "ABGGFlA5FpafAgo6tHcNmNjXmuSf",
"timestamp": "1518694235",
"text": {
"body": "Hello this is an answer"
},
"type": "text"
}]
}
Source: https://developers.facebook.com/docs/whatsapp/api/webhooks/inbound
Talking to Twilio my team got the response bellow:
Twilio does not manage a user database. Although this is a data
variable on the WhatsApp API, we are not leveraging it immediately as
it is not mandatory from the WhatsApp docs and our data structure may
not fully support this yet.
Again the Beta Nature of the Product will unveil product needs and
features in which we have not moved forward with how or if we plan to
support this.
There is at least one provider that I know that has this feature.
For me looks like Twilio recycled all the architecture they have for SMS without any regret of any drawbacks. We just found one, the absence of WhatsApp username in the message payload.
I reached Twilio asking for a deadline for this feature but until now I didn't receive any news yet.
The From is the WhatsApp username, do you mean how to programmatically extract the username (and if so, is there a particular language you are using)?
"From":"whatsapp:+97xxxxxxxxxx
There is no username, all you will get is the number of the user that sent the message, which is the "From" value, unless the sender tells you its username through the message body.

Hangouts Chat: how to retrieve project_id or client_id in incoming event request?

I have setup a fully operational chat bot in Hangouts Chat orchestrated by a tailored webserver. I would like now to be able to have this webserver to interact with other Hangouts bots that I created and to route some requests to some of my other servers that will have to know which bots initiated the event.
With other provider, such as Slack, the app_id is provided in the event request data.
But with hangouts, this is not the case. I could not find any data in the request body or headers that represent either project_id or client_id.
In a more simple way my question is : "How to identify the Hangouts bot that send me an event request?" :)
An event request's response will contain an Event instance in its body, which one of its fields will be an User object. That User object will contain a name field that will represent the user's id (whether it's a human or a bot).
It will look like this:
{
"name": "users/<id>",
"displayName": "<name that appears in the chat>",
"type": "BOT"
}
One month later, I finally found the time to answer my question :)
In order to identify the Hangouts project that is calling your server, when you receive an event from Hangouts Chat, you'll find in the incoming request the header Authorization whose value is something like Bearer abcd1234.
If you decode this JWToken (ie, abcd1234 in our example), in the resulting data, you'll have a field aud which is exactly the "project number" of your Hangouts app. This "project number" can be found at "https://console.cloud.google.com/home/dashboard?project=referenceofyourprojecthere".

Viber API get all subscribers

I am trying to create a Viber Bot and looking for the method that can run through all subscribers I have in the specific Public account
I checked out all methods from Documentation but haven't found anything like "get_all_subscribers" or "get_all_users". So as far as I understood I have to set up callbacks for subscriptions. And to work around this data
{
"event": "subscribed",
"timestamp": 1457764197627,
"user": {
"id": "01234567890A=",
"name": "John McClane",
"avatar": "http://avatar.example.com",
"country": "UK",
"language": "en",
"api_version": 1
},
"message_token": 4912661846655238145
}
So am I missing some methods and it's possible or I should work around callbacks only?
According to viber documenation Viber API
We recommend that you record the subscriber ID of each subscriber, as there’s no API for fetching all subscriber IDs for your bot. You can find the subscriber ID in the sender.id property of the Message callback, or the user.id property of the Subscribed callback. You can see whether a user is subscribed in the subscribed parameter of the conversation_started callback. Note that users’ first message to the bot will make them subscribed, but will not result in a Subscribed callback.
You can get information about your subscribers using Get Account Info endpoint.
Its response contains subscribers_count and members (list with fields: id, name, avatar and role).
P.S. the only thing that you need to check is if the public account subscribers are chat bot subscribers too.

Sample of Instagram webhook notification data

I am currently doing an integration to the Instagram API and would like my app to receive webhook notifications whenever there is new media on any Instagram account which has authorized my app via OAuth.
I've been able to write the code which sets up my app to receive notifications using the instructions here. However, I noticed that the Instagram API docs contain no information on what the data in a change notification will look like. My searches online have also come back void. I need sample Instagram webhook notification data so I can write code to parse the data and apply it for my purposes.
I would have gone ahead to expose my localhost to the internet via ngrok, so Instagram would send data to my callback URL when I post a photo to my Instagram account. However, I discovered that the Instagram API does not allow you use an ngrok URL as a callback URL.
Now the only option I have is to deploy my partially completed code to an actual web server. Hoping someone else who has previously integrated to the API can share the format of the webhook notification data. I really don't want to have to do deploy my application at this point.
I eventually had to deploy my partially completed code to a web server. I put a logger behind my webhook callback URL to record the notification data sent to it by Instagram. Below is what it looks like:
[
{
"object": "user",
"object_id": "123456789",
"changed_aspect": "media",
"time": 1506338651,
"data": {
"media_id": "1611605324545559190_123456789"
},
"subscription_id": 0
}
]
The Instagram webhook notification payload/data is a JSON array of objects, each of which contains information on a single change to an Instagram account. Each JSON object contains the following fields:
object: A string whose value is always "user"
object_id: The ID of the Instagram account on which the subject change occurred
changed_aspect: A string whose value is always "media"
time: The Unix epoch indicating when the subject change occurred
subscription_id: The ID of the Instagram subscription object through which this notification was sent. A subscription object is created to ask Instagram to send webhook notifications to your app and is essentially a callback URL.
data: A JSON object containing the following fields:
media_id: The ID of the new Instagram media object (photo, video or carousel) whose creation triggered this webhook notification

Instagram api not working for some api calls like follows, followedby etc

I am using instagram api calls for retrieving various details like media, followers list, followed-by list etc... Even though the user has followers api returns, some times with
{"pagination": {}, "meta": {"code": 200}, "data": []}
and sometimes with
{"meta": {"error_type": "APINotAllowedError", "code": 400, "error_message": "you cannot view this resource"}}
https://api.instagram.com/v1/users/1334757492/?access_token=2301663158.7114bad.addf9ad5791945e3a89a7fb1c3fca31c
The above api works fine. Also the api for getting media.
https://api.instagram.com/v1/users/1334757492/followed-by?access_token=2301663158.7114bad.addf9ad5791945e3a89a7fb1c3fca31c
The above api not working. Also api for follows list and some other api's
you must authorize your access-token on every API scope. and run it on sandbox mode. if you want activate it (on your case, you must at least authorize public_content and follower_list scope), visit this link :
activate public_content :
https://api.instagram.com/oauth/authorize/?client_id=[YOUR-CLIENT-ID]&redirect_uri=[YOURREDIRECT-URI]&response_type=token&scope=public_content
activate follower list :
https://api.instagram.com/oauth/authorize/?client_id=[YOUR-CLIENT-ID]&redirect_uri=[YOUR-REDIRECT-URI]&response_type=token&scope=follower_list
reference :
1. https://www.instagram.com/developer/authorization/
2. https://www.instagram.com/developer/sandbox/