Facebook-chat-api: Not Listen Message

Created on 31 Mar 2017  路  13Comments  路  Source: Schmavery/facebook-chat-api

extract My Code is

api.setOptions({
    listenEvents: true,
});

var stopListening = api.listen(function(err, event) {
    if (err) return console.error(err);
    switch (event.type) {
        case "message":
            var cmdStr = event.body ? event.body.toLowerCase() : "";

But not listen messages :(
image

debugging help

All 13 comments

how can anybody help? you didn't give us any information... no code, no errors :cry:

@ravkr , sorry men, but now yes!, please help me :'(

@Theblood you seem to be missing half your code!

@Schmavery
Testing echo code , and not listen

const login = require("facebook-chat-api");

// Create simple echo bot
login({email: "EMAIL_FB", password: "PW_FB"}, (err, api) => {
    if(err) return console.error(err);

    api.listen((err, message) => {
        api.sendMessage(message.body, message.threadID);
    });
});

try this before api.listen:

api.setOptions({
    selfListen: true
});

You can try @ravkr 's suggestion, but that should only make a difference if you're sending messages to yourself. If that doesn't work, try adding this before the call to api.listen and see if you get any log messages in the console when you receive a message:

api.setOptions({
    logLevel: 'verbose',
});

@ravkr testing you solution but not repair :'( , @Schmavery test your code watch
info listen Got answer in 1850 verb parseAndCheckLogin for (;;); {"t":"msg","seq":27,"u":100007502617855,"ms":[{"unseen":10,"unread":18,"recent_unread":18,"seen_timestamp":0,"realtime_viewer_fbid":100007502617855,"type":"inbox"}]}

is that all the logs you got? surprising
@bsansouci any ideas

@Schmavery It was from one moment to another, it could be that facebook changed again

@Theblood Can we see your full code? Are you sure you're calling api.sendMessage?

response of chrome:

for (;;); {"t":"msg","seq":281,"u":100011591116357,"ms":[{"ofd_ts":1490918195877,"delta":{"attachments":[],"body":"TEST","irisSeqId":"2379","messageMetadata":{"actorFbId":"100007502617855","messageId":"mid.$cAAAAAQz3urphUuuKn1bIaYoCVtPr","offlineThreadingId":"6253364124069581803","tags":["source:chat:web"],"threadKey":{"otherUserFbId":"100007502617855"},"timestamp":"1490918195871"},"class":"NewMessage"},"type":"delta","iseq":2379,"queue":100011591116357},{"st":0,"from":100007502617855,"to":100011591116357,"from_mobile":false,"attribution":null,"realtime_viewer_fbid":100011591116357,"type":"typ"},{"unseen":1,"unread":1,"recent_unread":1,"seen_timestamp":0,"realtime_viewer_fbid":100011591116357,"type":"inbox"}]}

@Theblood is this still a problem for you?

Closing for now as this is hard to reproduce without additional information. Please feel free to follow up when you have time and I can always reopen the issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nripendra picture nripendra  路  8Comments

rivc picture rivc  路  4Comments

GEOFBOT picture GEOFBOT  路  4Comments

WaffleCohn picture WaffleCohn  路  6Comments

tomekb530 picture tomekb530  路  6Comments