【问题标题】:How step.prompt(OAUTH_PROMPT) move automatically to next function in waterfall dialog in botbuilder version 4 in node js?step.prompt(OAUTH_PROMPT) 如何在节点 js 的 botbuilder 版本 4 中自动移动到瀑布对话框中的下一个函数?
【发布时间】:2019-08-23 10:12:20
【问题描述】:

目前,我在 Microsfot BotBuilder V4 NodeJs SDK 中使用 OAuthPrompt。 OAuthPrompt 主要用于 Azure 的机器人身份验证,但在通过机器人登录到 azure 后,我无法移动到瀑布对话框中的下一个功能,直到我向机器人发送另一条消息。如果我在登录后发送消息,则会调用 continueDialog(),因此会调用瀑布对话框中的下一个函数。

如何在不向机器人发送另一条消息的情况下自动移动到瀑布对话框中的下一个功能?

/**
     * 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();
    }

调用oauthPrompt()后,登录卡显示在bot.但是在那之后 loginResults() 函数不会自动调用,直到我发送另一条消息。两个函数都在同一个瀑布对话框中?

谁能告诉我如何在不向机器人发送另一条消息的情况下调用 loginResults 吗?

【问题讨论】:

  • 你在哪个渠道测试这个?
  • 我只是微软的bot框架模拟器。请帮帮我。
  • 感谢@StevenKanberg。你的说法让我明白了。这个问题会在微软团队中继续存在吗?
  • 不应该,但如果确实如此或出现了一些新问题,请在 Stack Overflow 上发布一个新问题,我们会提供帮助。

标签: node.js azure botframework


【解决方案1】:

这实际上是模拟器的正常(和预期)行为。有很多关于“为什么”的内容我不会触及。

简而言之,模拟器正在寻找一种特定类型的回调,由于模拟器在 OAuth 方面的工作方式,它永远不会收到这种回调。因为它从来没有收到这个回调,所以登录步骤不知道进入下一步,然后等待提示它的东西(即用户输入)。

这只是模拟器中的一个“问题”。当您在其他渠道中运行它时,这应该不是问题。

希望有帮助!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-11-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-30
    相关资源
    最近更新 更多