skip to Main Content

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:

Screenshot

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


  1. You can use cloudflare to get https instead of self-sign. Or you can use https://letsencrypt.org

    Login or Signup to reply.
  2. For just test you can use localtunnel. https://localtunnel.me/

    Login or Signup to reply.
  3. Extracted from here:

    New webhook subscriptions must use a secure HTTPS callback URL as of v2.5. With the next version of the Graph API we will stop sending updates to non-HTTPS callback URLs.
    If you need more information about setting up HTTPS for your callback URL, check out the Getting Started guide from Let’s Encrypt and the SSL Certificate Installation instructions from Digicert.

    And from here, and like @saturngod said:

    Self signed certificates won’t be accepted by facebook. Letsencrypt certificates works perfectly.

    Login or Signup to reply.
  4. To verify web hook use :-

    $_REQUEST["hub_token"] and $_REQUEST["hub_challenge"];
    

    First verify token to your page token and then print :-

    echo $_REQUEST["hub_challenge"];
    exit;
    
    Login or Signup to reply.
  5. I deployed my bot to Heroku, and they readily offers an HTTPS connections. For local development, I use ngrok, which also supports HTTPS forwarding.

    Ngrok

    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.

    Login or Signup to reply.
  6. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search