Connect multiple Messenger ChatBot on Single Facebook App

痴心易碎 提交于 2019-12-11 15:36:53

问题


I'm managing a Facebook page and Have a Facebook validated Node.js ChatBot on it. It Works fine and now I would like to know how to duplicate this ChatBot on multiple other Facebook pages. A single App, a single ChatBot and multiple Facebook pages linked on it.
For doing that, If I understood, I have to :
- Collect the page.id :

app.post('/webhook', (req, res) => {
    const data = req.body

    // Make sure this is a page subscription
   if (data.object === 'page') {
       // Iterate over each entry
       data.entry.forEach((pageEntry) => {
           // get the pageId
           const pageId = pageEntry.id
           ...


- Maintain an object mapping page ids to the access token associated with each page id: :

const accessTokens = {
    myPageId1: 'myPageAccessToken1',
    myPageId2: 'myPageAccessToken2',
}


- Then when sending the response, just specify the corresponding page access_token :

const callSendAPI = (pageId, messageData) =>
    rp({
        uri: 'https://graph.facebook.com/v2.8/me/messages',
        qs: { access_token: accessTokens[pageId] },
        method: 'POST',
        body: messageData,
        json: true,
     })


Now I only want to know how to ask user permission to manage all his pages and let him subscribe to my app with the Facebook page of his choice.

Can you please explain me more about this procedure please ? My goal is to create a platform in wich a user can choose among all this Facebook Page and connect my App to his page (like Chatfuel and other platform).

来源:https://stackoverflow.com/questions/45770548/connect-multiple-messenger-chatbot-on-single-facebook-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!