claudiajs / claudia-bot-builder

Create chat bots for Facebook Messenger, Slack, Amazon Alexa, Skype, Telegram, Viber, Line, GroupMe, Kik and Twilio and deploy to AWS Lambda in minutes
https://claudiajs.com/claudia-bot-builder.html
MIT License
1.84k stars 252 forks source link

Contrary to documentation, facebook echo messages are parsed and passed to bot #73

Closed thomasj02 closed 7 years ago

thomasj02 commented 7 years ago

In https://github.com/claudiajs/claudia-bot-builder/blob/master/lib/facebook/parse.js line 31, the Facebook parser tries to avoid parsing echo messages by checking messageObject.message.is_echo. This would work, except that the check never happens because echo messages pass the first check on line 4 (messageObject && messageObject.sender && messageObject.sender.id && messageObject.message && messageObject.message.text && !messageObject.message.quick_reply).

Either line 4 needs to check is_echo, or the ordering of the if/then statements needs to be changed.

For reference, here's a message that my bot got:

{
    "sender": "12345",
    "text": "Some text",
    "originalRequest": {
        "sender": {
            "id": "12345"
        },
        "recipient": {
            "id": "54321"
        },
        "timestamp": 1483413621558,
        "message": {
            "is_echo": true,
            "app_id": 314159,
            "mid": "mid.1483413621558:a9dc28cb84",
            "seq": 1022,
            "text": "Some text"
        }
    },
    "type": "facebook"
}
stojanovic commented 7 years ago

Fixed in v2.11.0, available on NPM. Thanks