Connecting third party Facebook page via messenger api - facebook

I have an application that uses the Facebook messenger api to send and receive messages through a Facebook page. This works great. Now I need to be able to have a user in my application link their page so that messages sent to their page will send webhooks to our endpoint, and also give us the ability to send messages through that page using an auth_token.
Is there any way to do this via api, or will each user have to manually create a Facebook app, generate an auth_token for their page, and set the webhooks url to our endpoint? I've read about messenger account linking but I don't think it's quite what I need, as I'm not just looking to request additional profile information.

After looking a bit deeper, I found that in order to do this you must perform an OAuth flow to get an auth_token for the user, then use the graph api to get an auth_token for the desired user's page. Then with the page auth_token you can make a POST request to the subscribed_apps endpoint, which will then add the page to the app's webhook events.

Related

Automatically subscribe pages to messenger webhook

I am working on a messenger platform that uses a messenger webhook to receive messages, and the Graph API to send messages. I currently need to go into my app settings and choose to subscribe pages that I already own.
I am wondering how I can subscribe pages that I don't own to my webhook. Is this possible if I have the Page Access Token? I can build an OAuth2 flow to get the Page Access Token, but I don't see what to do with it once I have it.
Any help is appreciated.
This can be achieved by making a POST call to /{page-id}/subscribed_apps endpoint with your Page Access Token.
API reference docs are at https://developers.facebook.com/docs/graph-api/reference/page/subscribed_apps/

How to make a messenger chat bot without a facebook app and webhook?

I went through the documentation for creating a chatbot for messenger platform.
All I find there, I need a server, which in the case used as a service for the Facebook platform.
The server also validates the webhook from facebook app.
Now I see, for a chatbot, I need a facebook app, webhook server and definitely a facebook page.
Then I find an application Flow XO, where I only put the page name and the bot is ready.
My question is, how they(flow.xo) can communicate facebook page without a Facebook app(appId, appSecret) and webHook.
My question is, how they can communicate facebook page without a Facebook app(appId, appSecret) and webHook.
They can’t.
They use their server and their app to communicate with the API, on behalf of the users that grant them access to their pages, by providing the necessary permissions when they log in to that app.
Facebook allows to create a Facebook App which integrates multiple chatbots. At Amio, we ask you for permission using Facebook OAuth. When you give us these permissions we send and receive message on your behalf. This allows you to create a chatbot using Amio API without need of creating a Facebook App.
Facebook Page is always needed as this is the entry point of users interacting with your bot. You can check Amio documentation for more detail.

Facebook Messenger API pages_messaging permission

I am creating an application where I need a user to be able to grant us access to their facebook page so that all incoming messages can flow through our application (as well as outgoing).
I have this all working correctly, but facebook will not approve my app due to the facebook permission pages_messaging and them "not receiving a response from my bot" (I have been denied three straight times). What am I doing wrong here? We are not using bots, do I even need the pages_messaging permission (I am using their webhook to get incoming page messages, and graph api to send outgoing)?
When submitting app, pages_messaging permission says:
Please provide the page that can be used to test this bot. Make sure the bot is properly connected and functional, otherwise your submission may be rejected.
Here is facebook's feedback from my submission (denied multiple times):
Thank you for your submission. We tested the messenger experience on your associated page and received no response from your messenger bot. Please resubmit with the new, improved version of your bot.
You got to create a bot to use the messaging API: https://developers.facebook.com/docs/messenger-platform/implementation
To just read/send messages:
https://developers.facebook.com/docs/graph-api/reference/v2.6/conversation/messages
You can use the /pageID/conversations endpoint to retrieve all conversations your page has had with FB profiles.
Next you can read/post to the /conversationID/messages endpoint to read/respond to a person.
And you can even subscribe to the conversations field for pages with webhooks.
You will need a page admin's page access token that has the read_page_mailboxes permission scope to set up the subscription, and to read/reply to messages.

Can i pull events from a facebook page using REST API

I want to pull events from any facebook page(given a page id) using REST Api. I am writing a server application and there is not facebook user login that we are using.
You could do this with an eternal Page Access Token via the /{page_id}/events edge.
See
https://developers.facebook.com/docs/graph-api/reference/page/events/

Facebook Graph Api access Alcohol Related Page

I am looking for a solution to fetch the feeds of an alcohol-related/age-restricted Facebook Brand Page by a website or back-end service to show these infos in that website for any user.
i.e: https://graph.facebook.com/JimBeam
The standard call results with an error or false.
I know the reason is the age-restictrion because of the relation to alcohol.
If I am connected to Facebook and add an access_token (user-token or page-token) to the request, I get everything I need, but it doesn't work if I am not connected.
If I request the page-token with offline_access, it also does not work when I am not connected to Facebook.
I am a bit confused with all this token types, offline_access, permissions and so on.
Is possible to get the fb-graph-feed of an age-restricted page and load that into a website?
To get an age-restricted feed you need to have a user access token that meets the criteria for the page. So if a user is visiting your site, they will need to authenticate your app, and then you can use the resulting access token to pull information to your website from that restricted page.
You should not be using a user's access token to display content to another user who does not meet the restrictions on the Facebook page.
An added problem is that Facebook does not expose a page's restrictions via the API, so you can't tell if a user has permission to see the page until your API request returns no data.