1

I have a messenger bot created in node. A user comments on the page and this kicks off a message sequence. It has previously been working however now I receive an error "The page does not have read_page_mailboxes or pages_messaging permission."

I have created a permanent access token as per instructions found in this overflow: facebook: permanent Page Access Token? - this did not work

I have tried to request to get the permission for read_page_mailboxes, however this was denied as this edge needs a platform to be included and login information, my bot uses none of these, just the comment-to-message functionality

I'm able to get the word that the user enters on the page however I'm unable to send a private message using the comment_id.

if(entry.hasOwnProperty('changes')) {
entry.changes.forEach(function(changes){
    let comp_comment;
    if(typeof changes.value.message !== "undefined") {
        comp_comment = changes.value.message.replace(/[^\w\s]/gi, '').trim().toLowerCase();
    }

    if(changes.field=="feed" && changes.value.item=="comment" && changes.value.verb=="add" && comp_comment == "enter") {
        let user = changes.value.from.name;
        let comment_name = user.replace(/ .*/,'');
        callPrivateReply(changes.value.comment_id, comment_name);
    }
})

}

Then this is my request function

function callPrivateReply(comment_id, first_name) {
let messageData = {
    "message": `this is the message I'm attempting to send`
}
request({
    "uri": 'https://graph.facebook.com/v2.12/'+comment_id+'/private_replies',
    "qs": { "access_token": PAGE_ACCESS_TOKEN },
    "method": 'POST',
    json: messageData
}, function (err, res, body) {
    if (!err && res.statusCode == 200) {
      console.log(body);
    } else {
      console.error("Failed calling Send API", res.statusCode, res.statusMessage, body.error);
    }

});

Tarrah_102
  • 11
  • 2

0 Answers0