【问题标题】:Facebook messenger bot Get Started ButtonFacebook Messenger bot 开始按钮
【发布时间】:2017-06-07 11:35:25
【问题描述】:

我正在用 js 构建我的第一个 Messenger 机器人,并且已经可以接收和回复消息并发送带有选项的卡片,但我已经尝试了一切设置开始按钮但没有成功...这是什么我已经这样做了:

我不知道我做错了什么或者我必须在哪里调用 facebookthreadAPI 函数。需要建议。

摘自 index.js:

function facebookThreadAPI(jsonFile, cmd){
// Start the request
request({
    url: 'https://graph.facebook.com/v2.6/me/thread_settings?access_token='+process.env.token,
    method: 'POST',
    headers: {'Content-Type': 'application/json'},
    form: require(jsonFile)
},
function (error, response, body) {
    if (!error && response.statusCode == 200) {
        // Print out the response body
        console.log(cmd+": Updated.");
        console.log(body);
    } else { 
        // TODO: Handle errors
        console.log(cmd+": Failed. Need to handle errors.");
        console.log(body);
    }
});}

摘自 fb-get-started-button.json:

{
   "setting_type":"call_to_actions",
   "thread_state":"new_thread",
   "call_to_actions":[
      {
        "payload":"action?POSTBACKHERE"
      }
   ]
}

【问题讨论】:

    标签: javascript facebook bots


    【解决方案1】:

    Facebook 现在提供了一个新的 API,用于设置“开始”按钮以及许多其他功能,例如问候文本和持久菜单,因此可以使用 messenger 配置文件 API 代替旧的 thread_setting API。例如,使用 curl

        curl -X POST -H "Content-Type: application/json" -d '{ 
          "get_started":{
             "payload":"GET_STARTED_PAYLOAD"
        }
       }' "https://graph.facebook.com/v2.6/me/messenger_profile?access_token=PAGE_ACCESS_TOKEN"    
    

    将 PAGE_ACCESS_TOKEN 替换为您的页面访问令牌,将 GET_STARTED_PAYLOAD 替换为您想要的任何有效负载。 查看完整的tutorial here

    【讨论】:

      【解决方案2】:

      我也有同样的问题。 Here你可以找到文档。

      我尝试执行该示例,但没有结果。

      curl -X POST -H "Content-Type: application/json" -d '{ "setting_type":"call_to_actions", "thread_state":"new_thread", “call_to_actions”:[ { “有效载荷”:“USER_DEFINED_PAYLOAD” } ] }' "https://graph.facebook.com/v2.6/me/thread_settings?access_token=PAGE_ACCESS_TOKEN"

      我的错误是:

      需要 pages_messaging 权限来管理对象

      但我的页面不公开。

      编辑:您可以找到解决方案Here。它不适用于页面管理员

      【讨论】:

        【解决方案3】:

        现在,使用新 API,我正在尝试使用该请求设置 GetStarted 按钮:curl -X POST -H "Content-Type: application/json" -d '{ "get_started":{ "payload":"start"} }' "https://graph.facebook.com/v2.6/me/messenger_profile?access_token=My_Token" 并获得{"result":"success"}。但是该按钮仍然没有出现在聊天中。所以,我还是不明白,这里有什么问题……

        【讨论】:

          猜你喜欢
          • 2020-06-03
          • 2017-02-05
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2017-05-06
          相关资源
          最近更新 更多