Skip to content

Instantly share code, notes, and snippets.

@soardex
Created March 25, 2017 14:16
Show Gist options
  • Save soardex/8a56f5856bff417a2c96ec1fd26906e5 to your computer and use it in GitHub Desktop.
Save soardex/8a56f5856bff417a2c96ec1fd26906e5 to your computer and use it in GitHub Desktop.
Use Test User To Test Messenger Bot
To get it to work please follow the steps:
1) Create test user by toggling the Authorize test users for this app and grant permissions "manage_pages" and "page_messaging".
2) Use the Edit Button and get an access token for this user (using v2.6). Please save this for later.
3) Use edit button to login as the test user
4) After login, create page as the test user
5) Use the user access token for the test user to get the page access token for this user. You can do this with the following call:
~~~
https://graph.facebook.com/v2.6/me/accounts?access_token=<TEST_USER_ACCESS_TOKEN>
~~~
6) Use this page access token to link your Facebook Application with your Page.
~~~
https://graph.facebook.com/v2.6/me/subscribed_apps?method=POST&access_token=<TEST_USER_PAGE_ACCESS_TOKEN>
~~~
7) After you have followed these steps you will receive RTU updates to your Test Page and be able to message your Test User from your Test Page.
In addition to the above you can replace your access token with a long-lived token if they are expiring too quickly for your tests. Please follow the documentation here:
~~~
GET /oauth/access_token?
grant_type=fb_exchange_token&amp;
client_id={app-id}&amp;
client_secret={app-secret}&amp;
fb_exchange_token={short-lived-token}
~~~
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment