Chatbot - generate page tokens for the pages you don't own using Facebook Login

前端 未结 2 2251
情歌与酒
情歌与酒 2021-02-03 15:54

Does anyone know how to install Facebook Chatbot on the page that you don\'t own?

I have created a chatbot and want to allow other FB Page to install my chatbot app, I c

2条回答
  •  甜味超标
    2021-02-03 16:15

    Here are the steps that i am following to subscribe a page to generate long lived page token (that never expires).

    1. Normal Facebook login with extra scopes manage_pages,pages_show_list,public_profile,pages_messaging scopes.
    2. On a server side api call, we extend the short term token to make it a long-lived token.

    3. List all the user pages using the account API. [GET]${FB_BASE_URL}/me/accounts?access_token=${accessToken}&fields=picture,id,name,access_token,username,perms

    4. Allow the user to select one of the pages and then you can use the subscribe API to subscribe that page to our application. [POST]${FB_BASE_URL}/${page.id}/subscribed_apps?access_token=${page.access_token};

    Notes:

    1. from accounts API each page will have a unique access_token, you will need to store this token somewhere to use later when replying to messenger, set get started button action, persistent menu,,, etc.
    2. you need to extend the login access token in order to get page_access token that does not expire.
    3. in that case all of your clients pages will be connected to a one Facebook application that will be connected to one bot, on your bot you will need to change the bot behavior depending on the recipient id (Page ID).
    4. In order to subscribe a page to an app the user should have "ADMINISTER" perms on that page, that's why you need to get the perms field in the account API and filter the results.

提交回复
热议问题