Facebook messenger bot入门按钮
我在js中构建了我的第一个messenger bot,并且已经可以接收和回复邮件并发送带有选项的卡片,但是我已经尝试了所有设置一个开始按钮但没有成功...这是我所做的:Facebook messenger bot入门按钮
我不知道我做错了什么或我在哪里必须调用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-开始-button.json:
{
"setting_type":"call_to_actions",
"thread_state":"new_thread",
"call_to_actions":[
{
"payload":"action?POSTBACKHERE"
}
]
}
Facebook现在提供了一个新的API来设置与许多其他功能,如问候文本和持久性菜单,所以,而不是使用旧的thread_setting API使用信使配置文件的开始按钮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_profileaccess_token=PAGE_ACCESS_TOKEN"
与你的页面访问令牌和GET_STARTED_PAYLOAD你想要的任何有效载荷替换PAGE_ACCESS_TOKEN。 请参阅完整tutorial here
我有同样的问题。 Here你可以找到文件。
我试图执行没有结果的例子。
卷曲-X POST -H “内容类型:应用/ 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。它不起作用的页面管理员
现在,随着新的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"}
。但该按钮仍然不会出现在聊天中。所以,我还是不明白,这里有什么问题...