Finally Facebook launched API for their messenger API for their messenger. This will allow us to create chat bots.
In getting started guide, I need to setup webhook. This requires webserver which resides in specific domain and must use SSL connection.
I have VPS which has static IP. I made self signed certificate and created simple Node JS web server which uses this certificate. First of all I need to verify token for webhook:
app.get('/webhook/', function (req, res) {
if (req.query['hub.verify_token'] === '<validation_token>') {
res.send(req.query['hub.challenge']);
}
res.send('Error, wrong validation token');
})
Then I launched this server application and In my facebook app dashboard I click to Verify and Save button.
It throws me this error message:
This means that Facebook does not want to accept my self signed certificate.
This brings a several questions:
Do I need to use SSL certificates only provided by Certificate Authorities in order to work with facebook messenger?
Working with Facebook messenger is far more difficult than Telegram.
6
Answers
You can use cloudflare to get https instead of self-sign. Or you can use https://letsencrypt.org
For just test you can use localtunnel. https://localtunnel.me/
Extracted from here:
And from here, and like @saturngod said:
To verify web hook use :-
First verify token to your page token and then print :-
I deployed my bot to Heroku, and they readily offers an HTTPS connections. For local development, I use
ngrok
, which also supports HTTPS forwarding.For new comers, I wrote this small tutorial for those who want to get started with the Facebook Messenger (Bot) API, from the first line of code to Heroku deployment. I found out that Heroku was a perfect fit for such a project, since I used Python
flask
+gunicorn
, all I needed for deployment really took 5 minutes to set up, and Heroku took care of the rest.I had the same error using Comodo SSL on Apache. In my case I was missing the SSLCertificateChainFile and just had to upload that bundle file and the path to file in my virtual host config and reload apache. Here is a link to install comodo SSL purchased from ssls.com https://helpdesk.ssls.com/hc/en-us/articles/203482651-How-to-install-a-SSL-certificate-on-Apache.