1

I've encountered following error message from Facebook even I've grant 'read_page_mailboxes' permission already.

2017-08-24T03:03:03.691425+00:00 app[web.1]: POST /webhook 500 5.551 ms - 101
2017-08-24T03:03:03.790925+00:00 app[web.1]: Failed calling Send API 403 Forbidden { message: '(#200) Requires read_page_mailboxes permission to manage the object',
2017-08-24T03:03:03.790930+00:00 app[web.1]:   fbtrace_id: 'ABmbB0iwWXQ' }
2017-08-24T03:03:03.790929+00:00 app[web.1]:   code: 200,
2017-08-24T03:03:03.790928+00:00 app[web.1]:   type: 'OAuthException',

and approval items:

enter image description here

enter image description here

and I've wrote following code in webhook as follow:

router.post('/', function (req, res) {
    var data = req.body;
    if (data.object == 'page') {
        data.entry.forEach(function(pageEntry) {
            var pageID = pageEntry.id;
            var timeOfEvent = pageEntry.time;

            if (pageEntry.hasOwnProperty('changes')) {
                pageEntry.changes.forEach(function(changes){
                    if(changes.field === "feed" && changes.value.item === "comment" && changes.value.verb === "add"){
                        var messageData = {
                            message: "hello"
                        };
                        callPrivateReply(messageData, changes.value.comment_id);
                    }
                });
            }
        });
    }
});

function callPrivateReply(messageData,comment_id) {
    request({
        uri: 'https://graph.facebook.com/v2.9/' + comment_id + '/private_replies',
        qs: { access_token: 'TOKEN' },
        method: 'POST',
        json: messageData
    }, function (error, response, body) {
        if (!error && response.statusCode == 200) {
            console.log(body);
        } else {
            console.error("Failed calling Send API", response.statusCode, response.statusMessage, body.error);
        }
    });  
}
PPShein
  • 13,309
  • 42
  • 142
  • 227
  • Are you using a page access token? – CBroe Aug 24 '17 at 07:14
  • @CBroe yap, sure. I used. – PPShein Aug 24 '17 at 07:32
  • Debug your user access token (or request `/me/permissions` using it), and _verify_ that it actually contains the permission. – CBroe Aug 24 '17 at 07:33
  • yap, I found there, https://ibb.co/g2XdK5 – PPShein Aug 24 '17 at 11:30
  • And where exactly are you passing the page access token in your API call? I only see you looping over the incoming webhook data, and since you are checking the page id there, I am assuming you are using this endpoint to manage updates from more than one page? The actual sending seems to happen inside `callPrivateReply`, but I don’t see you passing any page id or access token into that. – CBroe Aug 24 '17 at 11:42
  • @CBroe I've updated as show `callPrivateReply` function. – PPShein Aug 24 '17 at 12:50
  • So that is a fixed token that you stored somewhere? Does it belong to the actual page the comment was made on? – CBroe Aug 24 '17 at 13:06
  • @CBroe yap, sure. it stored config file. – PPShein Aug 24 '17 at 13:23
  • @ppshein can you tell me how you obtained `read_page_mailboxes` permission? I wanna do the same trick. When a certain user comments on my facebook page, I wanna send him a private message using chat bot. Do you have an idea what I have to do and how I can activate this option? I can't test my bot, because the option is disabled. – Killuminati Nov 15 '17 at 22:51

0 Answers0