【问题标题】:How to call a formflow dialog or a normal dialog from a QnAMakerDialog (FAQ type chatbot) at a certain condition on botbuilder-v3如何在 botbuilder-v3 上的特定条件下从 QnAMakerDialog(FAQ 类型聊天机器人)调用 formflow 对话框或普通对话框
【发布时间】:2019-01-08 11:13:50
【问题描述】:

我的情况如下。

我是 Bot-framework 的新手,正在制作一个使用 KB 服务与 QnA-Maker 类型通信的聊天机器人,并根据返回的特定答案,尝试通过 FormFlow 调用或开始引导式对话。我正在使用 SDK-V3(C#.net) 和 QnAMakerDialog 。

是否可以在 botbuilder-v3 上的特定条件下从 QnAMakerDialog 调用表单流对话框?

谢谢

【问题讨论】:

    标签: c# azure botframework qnamaker formflow


    【解决方案1】:

    第一件事:如果您现在开始,您不应该使用 SDK-V3:使用 v4,它通常可以使用几个月。 v3 将不会在未来发展(除了几个补丁)。

    然后,使用QnA Maker 查看 v4 的示例,这里:https://github.com/Microsoft/BotBuilder-Samples/blob/master/samples/csharp_dotnetcore/11.qnamaker/QnAMaker/QnABot.cs

    在这个示例中,您可以看到您可以在QnABot.cs 中实现您的逻辑:

    public async Task OnTurnAsync(ITurnContext turnContext, CancellationToken cancellationToken = default(CancellationToken))
    {
        // Handle Message activity type, which is the main activity type for shown within a conversational interface
        // Message activities may contain text, speech, interactive cards, and binary or unknown attachments.
        // see https://aka.ms/about-bot-activity-message to learn more about the message and other activity types
        if (turnContext.Activity.Type == ActivityTypes.Message)
        {
            // Check QnA Maker model
            var response = await _services.QnAServices[QnAMakerKey].GetAnswersAsync(turnContext);
            if (response != null && response.Length > 0)
            {
                // PUT YOUR LOGIC HERE
                //await turnContext.SendActivityAsync(response[0].Answer, cancellationToken: cancellationToken);
            }
            else
            {
                var msg = @"No QnA Maker answers were found. This example uses a QnA Maker Knowledge Base that focuses on smart light bulbs. 
                    To see QnA Maker in action, ask the bot questions like 'Why won't it turn on?' or 'I need help'.";
    
                await turnContext.SendActivityAsync(msg, cancellationToken: cancellationToken);
            }
        }
        else if (turnContext.Activity.Type == ActivityTypes.ConversationUpdate)
        {
            if (turnContext.Activity.MembersAdded != null)
            {
                // Send a welcome message to the user and tell them what actions they may perform to use this bot
                await SendWelcomeMessageAsync(turnContext, cancellationToken);
            }
        }
        else
        {
            await turnContext.SendActivityAsync($"{turnContext.Activity.Type} event detected", cancellationToken: cancellationToken);
        }
    }
    

    【讨论】:

    • 感谢@Nicolas,您能否参考 V4(C#.net)上的完整代码示例,其中在 QnAMaker 中的特定条件下,“formflow”对话框正在从“QnAMaker”对话框调用-使用 KB 服务的聊天机器人应用程序。谢谢,
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-09
    • 1970-01-01
    相关资源
    最近更新 更多