facebook-chat-api icon indicating copy to clipboard operation
facebook-chat-api copied to clipboard

Reply infinite when listen message for page

Open ngdanghau opened this issue 7 years ago • 10 comments

Hi. I have a problem with facebook-chat-api for fanpage. when i use listent for page, it reply infinite: ex:

  • User inbox: "Hey!"
  • Page reply: test bot: Hey! then countinue reply test bot: test bot: Hey! Can you fix that bug?

ngdanghau avatar Oct 14 '18 15:10 ngdanghau

could you potst your function for this problem ?

VietAnhPhan avatar Oct 26 '18 11:10 VietAnhPhan

const fs = require("fs");
const login = require("facebook-chat-api");
 
// Simple echo bot. It will repeat everything that you say.
// Will stop when you say '/stop'
login({appState: JSON.parse(fs.readFileSync('appstate.json', 'utf8'))},{pageID:00000000000}, (err, api) => {
    if(err) return console.error(err);
 
    api.setOptions({listenEvents: true});
 
    api.listen((err, message) => {
        api.sendMessage(message.body, message.threadID);
        
    });
});

Same problem.

Jeramy499k avatar Oct 26 '18 13:10 Jeramy499k

Bot infinite loop message.

Jeramy499k avatar Oct 26 '18 13:10 Jeramy499k

I guess turning off selfListen might be broken on pages? Anyone wanting to investigate this might want to fiddle with this conditional or at least add some log statement to see if the message is getting past that point: https://github.com/Schmavery/facebook-chat-api/blob/61ddf3ce02767ac5c04f93232567cc7e67fb1afe/src/listen.js#L377-L380

Does the message senderID match either the logged-in user id or the page id or is it something completely different?

It's been a while since anyone did much work on pages so I wouldn't be surprised if it was something small. Pages may have been converted to use a different message type and we might need to add the == pageid check somewhere else in listen.js

Schmavery avatar Nov 24 '18 00:11 Schmavery

You set pageID is your page's id or 00000000000 ??

hong4rc avatar Nov 25 '18 07:11 hong4rc

Set 000000000

ในวันที่ อา. 25 พ.ย. 2018 14:12 น. Hongarc <[email protected] เขียนว่า:

You set pageID is your page's id or 00000000000 ??

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Schmavery/facebook-chat-api/issues/690#issuecomment-441420472, or mute the thread https://github.com/notifications/unsubscribe-auth/AL4ukN-zFOgixcD-926nogTGVJLIBYr0ks5uykLPgaJpZM4XbLZr .

Jeramy499k avatar Nov 25 '18 09:11 Jeramy499k

Oh, you should set it to your page it. 00000000000 is example. If you use 00000000000, it same that you don't set it.

Please change it to your pageId and try again.

hong4rc avatar Nov 25 '18 10:11 hong4rc

No not this problem i know it but problem is bot spam same chat.

ในวันที่ อา. 25 พ.ย. 2018 17:42 น. Hongarc <[email protected] เขียนว่า:

Oh, you should set it to your page it. 00000000000 is example. If you use 00000000000, it same that you don't set it.

Please change it to your pageId and try again.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Schmavery/facebook-chat-api/issues/690#issuecomment-441430911, or mute the thread https://github.com/notifications/unsubscribe-auth/AL4ukDvWwyTHDbNODeJv4KM-hnj4JDeKks5uynQggaJpZM4XbLZr .

Jeramy499k avatar Nov 25 '18 10:11 Jeramy499k

Because you use 0 so v.message.sender_fbid.toString() === ctx.globalOptions.pageID is false

And your bot think that someone send to you.

hong4rc avatar Nov 25 '18 11:11 hong4rc

@JameMieKunG could you fix it? same issue here :(

nadien avatar Aug 05 '19 01:08 nadien