How to have facebook messenger bot in local, staging and production - facebook

Context
I'm working on a facebook messenger bot and have a workflow issue.
To create it i used ngrok to make a facebook test application hook on my local and it worked fine.
Now the bot is in staging for test and an other application have the webhook pointing to the stage server.
For the production server i intend to do a production application that will have webhook pointing on it.
Question
But since an application has to be attached to a page to start a conversation to it, how can i test several bots ?
Do i need 3 pages (local test, staging test and production) ?
Or is there a Facebook way to it ? (test version of app is not working for now on messenger bot, known bug)
Or maybe a good practice ?

You are looking for Test Apps in Facebook App Development. You can find this setting on the Developer Page on the top left where you can find a drop-down button to create a Test App.
I use to create my dev and staging environment.

Docs on this seem non-existent. It does seem like you need separate pages and bots for test/staging environments.
Here's what I did for the bot I made.
Make test/staging pages.
Unpublish those pages so they're not publicly searchable.
Give testers/devs Page Roles on the page so they can search for and find it.
Give those same testers/devs roles in the bot dashboard so they can actually chat with the bot.

Related

Making 'app' available to other people's pages

I've got incoming messages working via webhook, but what I cannot understand is how I make this available to other users.
I run a SaaS that's used by many different organisations, so I want to be able to give those organisations (who each have a subdomain on my domain) the ability to 'connect to facebook messenger', so that all of the messages to their facebook page (whatever that may be), come into their portal view on my platform.
The only way I can see this working, is by getting each user to register as a developer, and go through all the set up that I did to get my test example working.
But I must be missing something? What's the workflow to enable this, simply, so that users can connect in this way?
You can have multiple Facebook pages connected to your single Facebook app. But you would require permissions from Facebook for that. You can read about permissions here: https://developers.facebook.com/docs/facebook-login/permissions/

How can i test Facebook webhooks in a development environment?

In my app we have webhooks setup so Facebook notifies us of changes in an ad account.
It looks like you can only set 1 URL for webhooks so i cant remove the production endpoint because that would mess up the production environment.
Is there any way i can send webhooks to another URL?
The only option i can think of is just hardcoding some fake payloads and testing my code that way.
Does anyone know if there is a way to set some type of development endpoint?
EDIT:
For anyone that comes back to this, a test app can never be "live" this means that calls that require an app that is not in development will not work. Maybe the best workaround is to create a duplicate app and get it approved.
Facebook has introduced a feature called Test Apps a while ago.
https://developers.facebook.com/docs/apps/test-apps
You can create a test version of your production app, that will get its own app id, and have its own app dashboard where you can change most of the settings - including webhook endpoints.

Problems configuring an application in Facebook (website with Facebook login)

all:
We have a software developer building a web site with Facebook login for our company. They have told us to register a Facebook application.
For the moment, the beta application is hosted in a development environment. I would like to start testing also the Facebook integration. But when I access to the application page in Facebook, I get an error.
I think it might be related to an attribute I find in the first page of the app configuration. The attribute is called "Hosting URL".
The option seems to be linked to some kind of hosting service provided by Heroku. I don't know exactly what is that, but I would say we do not need it. We will use our own hosting server and, what's more, our application is developed in a language different that the one Heroku supports.
Could somebody confirm us which is the problem and, if it is possible, give us a hint to solve it?
Thank a lot in advance,
-The SportPoket team
The "Hosting URL" is meant to be the public web address of your finished production application. During development however, you only need to provide the URL for the app that is accessible from your web browser. If you are running a local web server on port 5000, http://127.0.0.1:5000/ will work.
Heroku is just one of the suggested hosting services for Facebook and you don't have to use it, but the documentation can be helpful. More about setting up a Facebook app dev env can be found here: https://devcenter.heroku.com/articles/facebook#1-creating-a-development-facebook-app

Facebook Api - Local development, Testserver, Liveserver ... How?

I'm working on a new website that uses the Facebook API for users to login and several implementations of the graph Api.
My workflow usually is:
Development on localhost
Development using MAMP/XAMPP or similar software
Push to server -> testing domain
A team of people can test the changes for a few days to see if everything works as planned.
Push to server -> live domain
Changes are live for public
Facebook uses the site URL in the appsettings and for security reasons, they will only redirect to that url... Problem is.. I have localhost and 2 different domains. How can I make this work?
Of course I could edit the hostsfile, but that only fixes it for localhost.. Still no solution for the testdomain.
Please tell me this is somehow possible! I'm getting more and more depressed with the Facebook API.
I usually register a facebook app per environment. (dev points to localhost etc..)
Haven't found a nicer way to do this either..
why still test facebook api on localhost?
You can try in heroku
This is
facebook official blog article
Also see the document in heroku
It is free to use.

How to do automatic functional test for Facebook Like button in local web server?

Our project is a Web application. We want to add Facebook Like button on our web pages. To test the functionality of Facebook Like works, we want to write some cucumber automatice functional tests.
The problem is, if a user (either real user or automatic test) click the Facebook Like button, the web page will send a message to Facebook server. And then Facebook server will callback to this web page to get some information (title/image/url/type etc, which are write in web page header meta tags). But our tests are running in local server, consequently the Facebook can not access. So there be something wrong.
So I'm wandering is there a solution to solve this problem. (Maybe not only for Facebook, but also any situation we want conversation between other systems and our local server)
In order for a Like Button to work, it has to be able to connect to the Facebook servers. There's no workaround, short of capturing the request and returning information, but I'm not even confident that would work. Can you not do the testing on a development server that can be accessed from the web?
You could .htaccess it so that only your team and the Facebook servers could connect to it.