claudiajs / claudia-bot-builder

Create chat bots for Facebook Messenger, Slack, Amazon Alexa, Skype, Telegram, Viber, Line, GroupMe, Kik and Twilio and deploy to AWS Lambda in minutes
https://claudiajs.com/claudia-bot-builder.html
MIT License
1.84k stars 253 forks source link

Fixed Facebook API v3.2 Messenger Bot #132

Closed prathmj closed 5 years ago

prathmj commented 5 years ago

(I can add more information to a README PR for set up purposes). The main change here is that Facebook's v3.2 Graph API has changed the URL of the POST request you need in order to setup a FB messenger chat bot. You will recall that when setting up a Facebook app and creating the webhook, you had to subscribe to certain fields. All you need for the chatbot to function is the "messages" field. In v3.2 of the Facebook Graph API, you now had to explicitly send FB, in the POST request, what fields you were planning on subscribing to. That is why 'messages' is now hard-coded into line 95. This POST request also required that you put the "pageID" of the Facebook page your chatbot was going to message from (the same page you got your Page Access Token from). This is either available in the settings of your Facebook page, or by viewing the source of the Facebook page and looking for the variable called "pageID".

Another weird addition is that chatbots now require a permission called "manage_pages". You can't actually give your FB app and chatbot the manage_pages permission from the main developer console. Instead, you need to go to this link: https://developers.facebook.com/tools/explorer/?classic=0 and from there choose your page, and add a new permission of "manage_pages".