Muggle
Muggle

Reputation: 79

args not returning expected LUIS result after implementing BotAuth

I have been creating a chat bot with MS Bot Framework in Nodejs and LUIS. I am recently trying to get certain information from the MS Graph API, and have (sort of) successfully implemented BotAuth and am able to get the information I want.

The issue I am facing now is that for the dialog that implements BotAuth, I am not able to get the usual args that comes with LUIS-intents triggered dialogs. Thus, I am not able to get any entities that the user might have entered. Other dialogs that do not implement BotAuth have no issues with this.

What I am getting now from args is:

{ response: undefined, resumed: 4 }

I am guessing that the issue lies with the [].concat part in this section:

bot.dialog('refreshSchDialog-oauth', [].concat(
    ba.authenticate("aadv2"),
    (session, args, skip) => {
        let user = ba.profile(session, "aadv2");
        session.endDialog(user.displayName);

        session.userData.accessToken = user.accessToken;
        session.userData.refreshToken = user.refreshToken;

        console.log('args');
        console.log(args);

        if (user.accessToken) {
            session.send('got leh');

            // valid access token, check if luis has any entities (MV name)
            // if there is, store conversationData and move to next dialog
            if (args.entities) {
                for (i = 0; i < args.entities.length; i++) {
                    if (args.entities[i].type == 'dbName') {
                        session.conversationData.mvName = args.entities[i].entity;
                        session.send(args.entities[i].entity);
                    }
                }
            }

            session.beginDialog('refreshSchDialog');
        } else {
            // no valid access token
            // TODO error message
        }
    }))
    .triggerAction({
    matches: 'refreshSchema',
    intentThreshold: 0.3
});

May I know why the args is not returning the information from LUIS?

Upvotes: 2

Views: 51

Answers (1)

Szymon Rozga
Szymon Rozga

Reputation: 18178

Looking at the BotAuth code it appears that the Auth dialog returns the user if properly authenticated or false if the dialog failed. It doesn’t copy over the args from LUIS. I would change your code so that the first function in your waterfall stores the LUIS data into session.dialogData, then call ba.authenticate and then use both results in your last waterfall step.

Upvotes: 3

Related Questions