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 254 forks source link

Facebook replies over and over endlessly #17

Closed Montoya closed 8 years ago

Montoya commented 8 years ago

Hi, built a simple Facebook integration that just echoes the text and it's replying over and over and over (and after the first reply it has lost the text from the request). screen shot 2016-07-07 at 6 47 33 pm

Montoya commented 8 years ago

Code:

const botBuilder = require('claudia-bot-builder');
const Promise = require('bluebird');
const lookup = Promise.promisify(require('whois').lookup);
const rp = require('request-promise');

// bunch of functions that aren't relevant to this

function dotcom(request) {

    switch(request.type) {
        case 'slack-message-action':
            return dotcom_slack_message_action(request);
            break;
        case 'slack-slash-command':
            return dotcom_slack_slash_command(request);
            break;
        case 'facebook':
            return 'You said: '+request.text;
            break;
        default:
            return 'Dunno who you are. I refuse to talk...'
            break;
    }

}

// user input is request.text
module.exports = botBuilder( request => dotcom(request) );
stojanovic commented 8 years ago

Ok, so, you enabled message delivery reports. We are sending them too through the Bot builder and they have the same type as the normal message (type: "facebook"). There's 2 things you can do:

  1. check if request.text exists (unless you are handling postbacks and attachments)
  2. disable delivery and read reports in fb app webhook settings.
stojanovic commented 8 years ago

We removed this in v1.3.2: https://github.com/claudiajs/claudia-bot-builder/releases/tag/v1.3.2

Montoya commented 8 years ago

Thank you!