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

Home Page:https://claudiajs.com/claudia-bot-builder.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Facebook replies over and over endlessly

Montoya opened this issue · comments

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

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) );

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.

Thank you!