Facebook Messenger webhook setup, but not triggered

James picture James · Apr 22, 2016 · Viewed 28.9k times · Source

So I'm trying to setup a bot for the new Facebook Messenger API.

I'm following the quickstart.

I setup the webhook ok, and see it in my webhooks,

I called this:

https://graph.facebook.com/v2.6/me/subscribed_apps?access_token=%3Ctoken%3E

and it did not throw any errors,

But when I go to the Page that I generated the access token on, and send a message, it does not call my webhook. I check the httpaccess, and it does not call it.

Any way to debug this or any ideas?

Also, one thing I'm still puzzled over is how to support managing multiple pages from one Facebook app? Anyone know the answer to this, or do you need to create anew app and get permission for every page?

Answer

Mukarram Khalid picture Mukarram Khalid · Apr 25, 2016

I have recently worked with the new chat bot API and there's a lot that can go wrong. So, here are some Ideas.

  • Make sure you've verified your webhook under the product settings tab.
  • subscribe your app to the page using your page access token. It returns {"success" : "true"} if everything goes right.

Important

  • Make sure the Facebook user from which you're sending the message is listed as the Admin or Developer or Tester in your app roles (https://developers.facebook.com/apps/YOUR_APP_ID/roles/). Messages from other users won't work unless your app is approved and publicly released.

  • Have you received any call back from the facebook api ? or is it just the messages? Take a look at the logs of your web server and check if you're getting any hits on the webhook. Also check the error logs.

  • Try hitting your webhook manually and see if it responds. You can use curl to generate a manual request. This is what the request from Facebook looks like:

Command:

curl -i -X POST -H 'Content-Type: application/json' -d '{"object":"page","entry":[{"id":43674671559,"time":1460620433256,"messaging":[{"sender":{"id":123456789},"recipient":{"id":987654321},"timestamp":1460620433123,"message":{"mid":"mid.1460620432888:f8e3412003d2d1cd93","seq":12604,"text":"Testing Chat Bot .."}}]}]}' https://www.YOUR_WEBHOOK_URL_HERE