Integration testing for Facebook messenger - facebook

FYI. I'm currently working on service that interact with Facebook messenger.
Facebook messenger-platform is my external service
https://developers.facebook.com/docs/messenger-platform/reference/send-api/
i want to make an integration test with facebook messenger send-api
according to facebook messenger Policy
"Businesses will have up to 24 hours to respond to a user. "
I have to use Facebook testing Account to texting to testing page
before run Integration test everytime also the testcase have to specific testing account's recipient id
is that anyway better than this ?
Expect response: message_id

Related

Are tfbnw.net email addresses suspicious for facebook login

I have a mobile app that allows logging in with facebook, when a user logs in I pull their email from the graph api but I just got a couple of logins with email addresses with #tfbnw.net domains which I guess is for test users while developing on facebook. I didnt generate these so is this someone doing something shady to login to my app or just expected behavior for some users given their settings?
Mobile app coded in react-native, using expo
Those seem to be the internal facebook QA team going through your APPs and manually checking if you're following all facebook's guidelines.
Facebook auditing your app basically.... or at least they did to mine because right after those #tfbnw.net email registrations came in, I checked my facebook app settings and sure enough, I got an alert and an email shortly after. But never received those #tfbnw.net emails before today on any other facebook logins.
I have checked my account and it looks like a generic test user Open Graph Test User gets created automatically, according to which product you enable in your app. It gets created for example, if you enable facebook login or messenger platform.
not something shady IMHO

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.

How to subscribe facebook test pages to facebook apps webhook

I am creating chatbot and want to connect on facebook.
I want to test my messenger chatbot in my page, but I must do app review and business verification first and I don't want to do that since I just developed my chatbot (or you can say this is staging environment).
I found that we can create test users, test pages, and test apps. I already create them all, but I cannot find a way to subscribe webhook from my test app to my test pages.
only real page appear in that select a page box.
How to subscribe my webhook to my test page? or is there any other way I can chat to my pages to test my chatbot without using business verification first?
Unfortunately, Facebook test apps / test pages / test users is buggy and seem to not work as expected. (I spent a few hours trying to figure that out)
They seem to focus on real user accounts.
We do not need to do business verification when Status of the app is: In Development
HINT: You can create a real user account in Facebook with any anonymous "false identity" name - so that your identity feels more anonymous and all the pages attached to it - whether published or not. (RISKS: But do not forget your password for this FB account, as you will not be able to recover this "second" FB account, as they might require your passport with that false identity "name" for recovery)
Then - you can create page by admin from real app in Facebook for Developers: Settings -> Advanced -> App Page -> Create Page
And then - just connect your bot to Webhooks in a standard way.
I struggled with this all day. Hopefully this can help someone out.
Here are the steps I took to get the interaction from a test user -> test page -> chatbot to work:
Create a test user within your developers.facebook App Dashboard (Roles, Test Users)
Login with the test user and create a page (Test Users -> Edit -> Login with this test user)
Get a long-lived page access token that has the scopes:
pages_messaging
pages_show_list
pages_manage_metadata
pages_messaging_subscriptions (this is needed to register the webhook)
Use the page access token to programmatically register a webhook for the test page (don't think you can manually add from the dashboard):
POST to https://graph.facebook.com/v9.0/{testPageId}/subscribed_apps?subscribed_fields=messages,messaging_postbacks&access_token={longlivedPageAccessToken}
note: using graphAPI 9.0 for all requests

Link facebook messenger with facebook login on app

I have a facebook messenger bot that sends a webhook to my web app. People can login to my app via facebook login.
The first user contact is normally with my facebook bot on which they can create a profile. When they make contact I take their facebook id, name, profile pic, etc.
Users can then login with facebook to my web app to enhance their profile.
My problem is facebook uses different scoped ids for messenger and their login.
How can I recognise if a user has already been on my facebook bot if they use my web app, and vice verca.
I think it has something to do with the business mapping api: https://developers.facebook.com/docs/apps/for-business but I'm struggling to understand how it works.
I am sending a get request using:
GET /me?fields=token_for_business
But the docs do not specify the full url to use. I'm also unsure if you can use this in developer mode.
facebook provides an id-matching api
for the app and pages owned by the same business manager. More informations:
https://developers.facebook.com/docs/messenger-platform/identity/id-matching

Sending notifications via Messenger Bot to Facebook OAuth registered users

Let's say you have a site that accepts Facebook OAuth registrations/login. Today, the typical pattern is to capture the user's email and send them notifications via that channel. Fine.
Messenger bots have now opened up an opportunity to engage with users directly via Messenger rather than relying on email. In markets where Messenger is heavily used and email hardly ever, notifications via Messenger are a big deal.
Reading the documentation my understanding is that Facebook user id's are application scoped. I wouldn't be able to send a user registered via Facebook's OAuth a message on Messenger.
Has anyone done this? Is it possible or at least being considered in a future spec?
Use checkbox plugin for messenger in web app flow, this is meant for the same purpose!