1
votes

Currently, I am using the OAuthPrompt in Microsfot BotBuilder V4 NodeJs SDK. The OAuthPrompt is mainly used for bot authentication with Azure, but after logging in to azure through the bot, I am not able to move to next function in the waterfall dialog until I send another message to the bot. If I send a message after login, then continueDialog() is called, so next function in waterfall dialog is invoked.

How do I automatically move to the next function in the waterfall dialog without sending another message to bot?

/**
     * Waterfall step that prompts the user to login if they have not already or their token has expired.
     * @param {WaterfallStepContext} step
     */
    async oauthPrompt(step: any) {
        await step.prompt(OAUTH_PROMPT);
    }

    /**
     * Waterfall step that informs the user that they are logged in and asks
     * the user if they would like to see their token via a prompt
     * @param {WaterfallStepContext} step
     */
    async loginResults(step: any) {
        let tokenResponse = step.result;
        if (tokenResponse != null) {
            await step.context.sendActivity('You are now logged in.');
            return await step.prompt(CONFIRM_PROMPT, 'Do you want to view your token?', ['yes', 'no']);
        }

        // Something went wrong, inform the user they were not logged in
        await step.context.sendActivity('Login was not sucessful please try again');
        return await step.endDialog();
    }

After the oauthPrompt() is called, the login card is displayed in bot. But after that loginResults() function is not automatically invoked until I send another message. Both functions are in same waterfall dialog?

Can anyone tell me how to call loginResults without sending another message to the bot, please?

1
What channel are you testing this in?Steven Kanberg
I am just the microsoft bot framework emulator. Please help me.Prakash
Thanks @StevenKanberg. Your statement made me clear. Will this problem continue in microsoft teams?Prakash
It shouldn’t but if it does or some new problem shows up, post a new question on Stack Overflow and we’ll help.Steven Kanberg

1 Answers

0
votes

This is actually normal (and expected) behavior for the emulator. There is a lot that goes into the 'why' that I won't touch.

In short, tho, the emulator is looking for a specific kind of callback that it won't ever receive because of how emulator works with respect to OAuth. Because it never receives this callback the login step doesn't know to advance to the next step and, subsequently, waits for something to prompt it (i.e. user input).

This is only a "problem" in emulator. When you run this in other channels it shouldn't be an issue.

Hope of help!