我会尽力解释我遇到的问题。当我从自己的 FB 帐户使用机器人时,一切正常。
但是当我要求其他人使用它时,机器人没有回应他们,尽管我在 dev.FB 的 pages_messaging 上有绿色勾号。
使机器人写回复的基本 sendText 函数:
function sendText(sender, text){
let messageData = {text : text}
console.log("comes here too" + " message data: " +messageData);
request({
url: "https://graph.facebook.com/v2.6/me/messages",
qs : {access_token : token},
method: "POST",
json: {
recipient : {id: sender},
message : messageData
}
}, function(error, response, body){
if ( error){
console.log("sending error")
} else if(response.body.error){
console.log("messageData: " + messageData + "recipient " + sender)
console.log("response body error" + response + " body "+body)
}
})
}
然后我遇到的错误是其他人试图连接到机器人:我通过 3 个 console.logs 得到以下信息:
comes here too message data: [object Object]
messageData: [object Object]recipient (MyOtherAccountIDIsHere)
response body error[object Object] body [object Object]
我最初的想法是 bot-review 没有正常工作,页面实际上没有被批准。由于在我的开发人员 FB 帐户上,我可以正常与机器人聊天,没有任何问题(如果没有出现 2 个 console.logs,则最后一个)
请让我知道您的想法,如果需要,愿意提供任何其他信息。