3

Introduction I have a Facebook APP and it is already published and approved to access the manage_pages and pages_messaging permissions. Facebook Login and Messenger are also installed. I also have a Webhook set and it works well.

My objective I would like to make it easy for my users to create and publish a bot within the app, like what Chatfuel does. The user logins in using Facebook, create a new bot, link to a page and automatically the bot is available for use. The user will not be involved in manual configuration of the bot publishing process but rather simply pointing the page they would like the bot to appear.

What I have done so far

  • Login user with Facebook and collect their access_token and user_id using the app_token
  • Using the token, retrieve the pages owned by the user GRAPH_API_URL/me/accounts?access_token=USER_ACCESS_TOKEN
  • From the results obtained above, I'm able to display the pages to the users for them to choose where to publish the bot. I'm able to get the selected PAGE_ID and PAGE_ACCESS_TOKEN for use in the next step
  • I then send a POST request to subscribed the app to the page. Remember the app is the same one they used to login and approve the needed permissions as per my defined scope ('email', 'public_profile', 'manage_pages', 'publish_pages', 'pages_show_list')

Subscribing app to a page, I send a POST request to:

https://graph.facebook.com/v2.10/PAGE_ID/subscribed_apps?access_token=PAGE_ACCESS_TOKEN

The response I got was a success:

{"success": true}

The Problem Using the pages I own the process works well and I'm able to chat with the bots and from the app dashboard I can clearly see the pages have been added to the subscription list. My users are able to go through the all process, and from the logs, they also get a success response but their pages are not added and they cannot chat with the bot. To verify their subscriptions, I sent a GET request to https://graph.facebook.com/v2.10/PAGE_ID/subscribed_apps?access_token=PAGE_ACCESS_TOKEN and the response is positive as shown in the example below:

{
  "data": [
    {
      "link": "http://mywebsite.com/",
      "name": "MyApp",
      "id": "1438393....."
    }
  ]
}

From the highlighted steps, is there anything I might be missing? How can I get the above done properly? Thanks in advance for your input.

Cheruiyot Felix
  • 1,557
  • 5
  • 26
  • 42
  • 4
    And where exactly are you asking for `pages_messaging` permission …? – CBroe Oct 23 '17 at 07:46
  • CBroe, I think I'm missing that under my scope. It is approved but not there. Let me add it and try. I revert in a moment. – Cheruiyot Felix Oct 23 '17 at 07:54
  • Thank you @CBroe it works well. Thank you very much – Cheruiyot Felix Oct 23 '17 at 08:01
  • Hey ! its strange that I am also stuck on the same issue. I am also trying to build something similar. this question is 9 months old so i am guessing that you got a lead on this issue would you like sharing it with me. – Amit Kumar Jul 26 '18 at 08:18
  • Please, if anyone knows how to create / modify the messenger webhook of an app client, can you share? – JG73 Dec 28 '20 at 17:51

0 Answers0