botframework-sdk icon indicating copy to clipboard operation
botframework-sdk copied to clipboard

Prompts Choice, Confirm, Attachment Not Behaving Correctly on Facebook

Open oztheozoz opened this issue 10 years ago • 7 comments

With Prompts.choice|confirm|attachment, if you type an unexpected input, the bot automatically replies with the message 'default_choice', 'default_confirm' and 'default_file'.

Here's an example with the demo-facebook app included in BotBuilder. screen shot 2016-09-16 at 11 34 35 pm screen shot 2016-09-16 at 11 27 59 pm

Prompts.confirm performs even worse since selecting "confirm_yes" or "confirm_no" will cause the bot to re-prompt indefinitely until you type "yes" or "no". screen shot 2016-09-16 at 11 28 32 pm

Perhaps something underlying in the FB API changed and thus is messing things up? It used to work fine. I am using BotBuilder 3.2.3

[UPDATE] So it turns out I made a mistake and am not using 3.2.3 but the latest changes on master. I did find that commit b462d90 introduced some changes that is causing these issues not seen in BotBuilder 3.2.3

oztheozoz avatar Sep 17 '16 06:09 oztheozoz

Thanks @oztheozoz. @Stevenic, any thoughts?

dandriscoll avatar Sep 17 '16 21:09 dandriscoll

Thanks @oztheozoz for pointing this out. We haven't published those updates to the SDK yet so let me verify that everything is still working as expected before we do.

Stevenic avatar Oct 03 '16 21:10 Stevenic

I also got this issue. The problem is in the local dev env (on Windows 10) i got the right message (default_file is parsed to the default in locale/en/BotBuilder.json", but when I deployed to Heroku it just shows "default_file"... Still debugging...

bobzsj87 avatar Oct 26 '16 07:10 bobzsj87

I opened the node_debug and found that at least on Heroku, the DefaultLocalizer didn't load the data.

2016-10-26T09:12:22.523354+00:00 app[web.1]: ChatConnector: message received.
2016-10-26T09:12:23.089989+00:00 app[web.1]: localizer::load requested for: en
2016-10-26T09:12:23.091818+00:00 app[web.1]: localizer::in directory: /app/node_modules/botbuilder/lib/locale/en
2016-10-26T09:12:23.092013+00:00 app[web.1]: localizer::in file: BotBuilder.json
2016-10-26T09:12:23.092283+00:00 app[web.1]: localizer::parsing /app/node_modules/botbuilder/lib/locale/en/botbuilder.json
2016-10-26T09:12:23.092684+00:00 app[web.1]: localizer::in file: index.json
2016-10-26T09:12:23.092773+00:00 app[web.1]: localizer::parsing /app/node_modules/botbuilder/lib/locale/en/index.json
2016-10-26T09:12:23.094363+00:00 app[web.1]: localizer::directory complete: /app/node_modules/botbuilder/lib/locale/en
2016-10-26T09:12:23.094989+00:00 app[web.1]: localizer::in directory: /app/node_modules/botbuilder/lib/locale/en
2016-10-26T09:12:23.095060+00:00 app[web.1]: localizer::in file: BotBuilder.json
2016-10-26T09:12:23.095128+00:00 app[web.1]: localizer::parsing /app/node_modules/botbuilder/lib/locale/en/botbuilder.json
2016-10-26T09:12:23.095348+00:00 app[web.1]: localizer::in file: index.json
2016-10-26T09:12:23.095500+00:00 app[web.1]: localizer::parsing /app/node_modules/botbuilder/lib/locale/en/index.json
2016-10-26T09:12:23.096270+00:00 app[web.1]: localizer::directory complete: /app/node_modules/botbuilder/lib/locale/en
2016-10-26T09:12:23.096817+00:00 app[web.1]:
2016-10-26T09:12:23.097448+00:00 app[web.1]: localizer::loaded requested locale: en
2016-10-26T09:12:23.132477+00:00 app[web.1]: prompts::sendPrompt called
2016-10-26T09:12:23.132703+00:00 app[web.1]: prompts::sendPrompt setting ns to BotBuilder
2016-10-26T09:12:23.132889+00:00 app[web.1]: localizer::gettext locale:en msgid:default_file ns:BotBuilder
2016-10-26T09:12:23.133357+00:00 app[web.1]: localizer::trygettext locale:en msgid:default_file ns:botbuilder fb:en key:botbuilder:default_file
2016-10-26T09:12:23.133466+00:00 app[web.1]: localizer::trygettext returning: null
2016-10-26T09:12:23.133554+00:00 app[web.1]: localizer::gettext returning: default_file

While I can get the data on my local machine. I tried to dump info like this

let a = require('botbuilder/lib/DefaultLocalizer');
            console.log(a['DefaultLocalizer'].map['en'])

And it is an empty object on live...

bobzsj87 avatar Oct 26 '16 09:10 bobzsj87

@Stevenic

I think I got the bug. The code in DefaultLocalizer.js uses toLowerCase() which is ok in Windows, but filepath in Linux is case sensitive.

 var filePath = (localeDir + "/" + filename).toLowerCase();
        if (DefaultLocalizer.filesParsedMap[filePath]) {
            cb(null, DefaultLocalizer.filesParsedMap[filePath]);
        }
        else {
            logger.debug("localizer::parsing %s", filePath);
            fs.readFile(filePath, 'utf8', function (err, data) {

Could also be a problem here this.botLocalePath = settings.botLocalePath.toLowerCase();

bobzsj87 avatar Oct 26 '16 09:10 bobzsj87

Btw, @Stevenic the error from fs.readFile is not popped up or logged in the debug. Better to log somewhere.

bobzsj87 avatar Oct 26 '16 09:10 bobzsj87

@bobzsj87 I've removed the call to lowercase the path (I didn't actually write that code) and there should be a patch out today.

Stevenic avatar Oct 27 '16 20:10 Stevenic