By using the example code from listen documentation, every previous message is marked as readed.

Have someone same behaviour?
I looked on mark_as_read.php request, but not looks like something has been changed.
I think I can reproduce. But for me, it's not the previous message that is marked as read, it's the first message is marked as read and then the markAsRead function won't work again.
I tested with this:
api.listen((err, message)=>{
if(message.type == 'message'){
console.log('New message');
api.markAsRead(message.threadID, (err)=>{
if(err) return console.log(err);
console.log('Marked as read');
});
}
});
Only the first time the api receives a message will it actually mark it as read. It will not mark as read again until I restart the app. This applies to different threads too. In effect, only the first message the api marks as read will actually be marked as read regardless of thread.
I looked on mark_as_read.php request,
@GAMELASTER Not sure if I'm being dumb but where are you getting mark_as_read.php from? I'm seeing change_read_status.php on facebook and it's also what the api is using.
@mangopearapples sorry, I'm beign dumb! I have change_read_status.php too, but by mistake written wrong name 馃槅
@mangopearapples actually it's have something similar behaviour like you. Just look gif:

Actually yeah I get the exact same results as you. I just couldn't see the previous "seen" status on the normal facebook home page.
I haven't seen this bug yet, but I will investigate it tomorrow
If message.body != undefined should fix the issue. You receive undefineds occasionally. Make sure u are marking sure u remove all undefineds.
If message != undefined {
If message.thread != undefined {
Api.read ....
}
}
Once you have filtered out all undefineds test. And report back
Try testing function (err) instead of => it's better and more reliable
Interestingly, when the program above is running, even the actual facebook messenger on the website will not mark the latest message as read. However when I view the message in Android's FB messenger, it will then mark the message as read correctly.
@bobland1 I'm not sure if checking if the message.body is undefined is the right approach. You should check message.type and err, if that doesn't work, there's a bug in the api 馃槢
@mangopearapples I wouldn't be surprised if this could be a problem on facebook's end, but it's nice to investigate anyway :)
@Schmavery I was using it more as an example. I meant for him to filter out the undefineds of message, message.threadID and message.type
if message != undefined {
if message.type != undefined {
if message.threadID != undefined {
api.markAsRead(message.threadID, function (err) {
if(err) return console.log(err);
console.log("Marked as read");
});
}
}
}
@bobland1 my point was that I don't think this is the right solution to this problem, but to each their own.
Oh I understand :) sorry
Sometimes messenger POST's to mark_seen.php which markAsRead doesn't do. Maybe this has something to do with this issue.
The form data for the mark_seen.php request is just seen_timestamp: [same timestamp as change_read_status.php]

I have tried adding the POST request into markAsRead() however it still doesn't work.
@mangopearapples lol, so I don't has been blind and there is really a mark_seen.php request haha 馃槅
It's again have another behaviour! Now it's sometimes read until end, sometimes ignoring few messages and then again to end
馃槙 mark as read seems to work perfectly on our bots these days... I'm assuming people are working from the latest version? (I just published 1.4.0 btw)
Closing as it seems like it's working. Please re-open if it's still an issue.
We have 2 bots running on this API that are working fine.