Facebook - Bot07 May 2018
- best practices
- configure webhook
- generate page access token
- configure messenger
- set up account linking
- Facebook for Developers
- page access token
- Access Token Debugger
While recognizing free-form typed responses can be valuable, it can also be challenging to implement and tedious for people interacting with your bot. Make use of buttons, quick replies, and the persistent menu to structure user input. This can help streamline interactions and clearly communicate expectations.
Map out Interactions
Do not use standalone questions. This could imply free form interaction and encourage people to respond in ways you do not support. If you do pose questions, add buttons with specific answers to the message for people to choose from.
The Messenger Platform sends an event to your webhook whenever an action occurs in a conversation with your bot. Your webhook is a single HTTPS endpoint (usually /webhook) exposed by you that accepts POST requests. This is where your bot processes and responds to all incoming webhook events.
The Messenger Platform supports a standard set of webhook events that you may subscribe your webhook to during the setup process. At a minimum, you should subscribe to the messages and messaging_postbacks webhook events to be able to implement basic Platform features in your bot.
edit callback URL
subscribe webhook to page events
generate page access token
PAT is required to send messages on behalf of selected page.
see Facebook - API on how to generate PATs in either FD or GAE.
get started button
make sure you Messenger app is subscribed to
set up account linking
AFAIK yes, you can open a webview with your own hosted website where you grab the messenger user id, and tell the user to click on “login with facebook”. Then you get the APP ID and can save a relation in your database with the messenger user id.
you must be app admin (not page admin) to receive webhooks events when user sends a message to a page associated with your Messenger app (bot):
Page token is required to start using the APIs. This page token will have all messenger permissions even if your app is not approved to use them yet, though in this case you will be able to message only app admins.
you’ll be able to message users having ANY app role (admin, developer, tester)
- not necessarily admin role.
about ASID vs. PSID
When a person uses Facebook Login on a website or a mobile app, an ID is created for the specific Facebook app, which is called app-scoped ID. When a person interacts with a business via Messenger, an ID is created for the specific Page associated with the bot in Messenger, which is called Page-scoped ID.
NOTE: PSID is the same for all applications subscribed to this page messages.
Account Linking Failed
I see the error in browser when trying to complete account linking flow.
I haven’t subscribed my webhook to
messaging_account_linking page event => add
messaging_account_linking page subscription field in Messenger settings:
Edit Page Subscription Fields
Error validating access token: The user has not authorized application
I got this error when I tried to send login button to user on behalf of Messenger app (chat bot which sends and receives messages using Facebook Page) using PAT => this access token appears to be invalid.
the point is that I have de-authorized Messenger app (by removing business integration in Facebook account settings) making token generated for this page invalid.
ATD shows error for this PAT now:
Error validating access token: The user has not authorized application <app_id>
solution is to authorize application once again by generating new PAT:
select required page and copy generated PAT into Messenger app.