C# 在用户选择对话框列表上的“以上任何一项”选项后,如何创建流程?

C# 在用户选择对话框列表上的“以上任何一项”选项后,如何创建流程?,c#,dialog,botframework,qnamaker,C#,Dialog,Botframework,Qnamaker,我试图在用户没有选择上述任何一项后创建一个进程 如您所知,当用户输入模糊消息时,QnA Maker会回复相关的多个问题列表。在列表的底部,我们看不到上述任何一项 我想在用户没有选择上面任何一个框之后创建一个进程。我已经尝试过重写BasicQnAMakerDialog,但无法做到 如果有人知道怎么做,请告诉我 我想在用户没有选择上面任何一个框之后创建一个进程 您可以尝试重写DefaultWaitNextMessageAsync方法,并检测用户是否未选择上述任何选项,以下代码段供您参考 protec

我试图在用户没有选择上述任何一项后创建一个进程

如您所知,当用户输入模糊消息时,QnA Maker会回复相关的多个问题列表。在列表的底部,我们看不到上述任何一项

我想在用户没有选择上面任何一个框之后创建一个进程。我已经尝试过重写BasicQnAMakerDialog,但无法做到

如果有人知道怎么做,请告诉我

我想在用户没有选择上面任何一个框之后创建一个进程

您可以尝试重写DefaultWaitNextMessageAsync方法,并检测用户是否未选择上述任何选项,以下代码段供您参考

protected override async Task DefaultWaitNextMessageAsync(IDialogContext context, IMessageActivity message, QnAMakerResults result)
{
    if (message.Text.Equals("None of the above."))
    {
        // your code logic

        await context.PostAsync("You selected 'None of the above.'");
    }

    await base.DefaultWaitNextMessageAsync(context, message, result);
}
测试结果:

更新:

你想问什么问题?->用户输入等等

你想问什么样的问题?在DefaultWaitNextMessageAsync方法内发送给用户,并等待用户输入

完整的示例代码:

测试结果:


你说你试图推翻BasicQnAMakerDialog;你能帮我们发布代码吗?谢谢你的快速回复。公共类BasicQnAMakerDialog:QnAMakerDialog{public BasicQnAMakerDialog:basenew QNamakerService新QNamakerAttributeConfiguration Manager.AppSettings[QnAAuthKey],ConfigurationManager.AppSettings[QnAKnowledgebaseId],在常见问题解答中没有很好的匹配,0,5,ConfigurationManager.AppSettings[QnAEndpointHostName]{}受保护的重写异步任务响应来自QNamakerResultAsyncIDialogContext上下文,IMessageActivity消息,QnAMakerResults结果{}}非常抱歉,我不知道如何将跳线上载到此站点。 但实际代码是这样的。我想我需要做一个特定的方法来覆盖 BasicQnAMakerDialog。是否正确?我已尝试添加类似ifmessage.Text.equals的内容上述内容均无。。但是我做不到。我真的很感激你的回答。<我能成功地实现它!谢谢!Hi@Gon,如果回复帮助您解决问题,您可以将其标记为已接受的答案,这也可以帮助其他社区成员快速找到答案并解决类似问题。Hi@Fei Han。我能再问一个问题吗?在用户没有选择以上任何一项后,我希望用户输入评论,比如你想问什么?->用户输入等等。我可以添加这种函数吗?我想我不能在DefaultWaitNextMessageAsync中调用其他方法。我想使用上下文。等等,但我做不到。如果你知道怎么做,请告诉我。此外,我不知道如何接受这个网站上的答案。请告诉我怎么做。对不起打扰你了。
namespace Microsoft.Bot.Sample.QnABot
{
    [Serializable]
    public class RootDialog : IDialog<object>
    {
        public async Task StartAsync(IDialogContext context)
        {
            /* Wait until the first message is received from the conversation and call MessageReceviedAsync 
            *  to process that message. */
            context.Wait(this.MessageReceivedAsync);
        }

        private async Task MessageReceivedAsync(IDialogContext context, IAwaitable<IMessageActivity> result)
        {
            /* When MessageReceivedAsync is called, it's passed an IAwaitable<IMessageActivity>. To get the message,
             *  await the result. */
            var message = await result;

            context.ConversationData.SetValue<bool>("isnotdefaultmes", false);

            var qnaAuthKey = GetSetting("QnAAuthKey");
            //var qnaKBId = Utils.GetAppSetting("QnAKnowledgebaseId");
            var qnaKBId = ConfigurationManager.AppSettings["QnAKnowledgebaseId"];
            var endpointHostName = ConfigurationManager.AppSettings["QnAEndpointHostName"];

            // QnA Subscription Key and KnowledgeBase Id null verification
            if (!string.IsNullOrEmpty(qnaAuthKey) && !string.IsNullOrEmpty(qnaKBId))
            {
                // Forward to the appropriate Dialog based on whether the endpoint hostname is present
                if (string.IsNullOrEmpty(endpointHostName))
                    await context.Forward(new BasicQnAMakerPreviewDialog(), AfterAnswerAsync, message, CancellationToken.None);
                else
                    await context.Forward(new BasicQnAMakerDialog(), AfterAnswerAsync, message, CancellationToken.None);
            }
            else
            {
                await context.PostAsync("Please set QnAKnowledgebaseId, QnAAuthKey and QnAEndpointHostName (if applicable) in App Settings. Learn how to get them at https://aka.ms/qnaabssetup.");
            }

        }

        private async Task AfterAnswerAsync(IDialogContext context, IAwaitable<IMessageActivity> result)
        {
            // wait for the next user message
            context.Wait(MessageReceivedAsync);
        }

        public static string GetSetting(string key)
        {
            //var value = Utils.GetAppSetting(key);
            var value = ConfigurationManager.AppSettings[key];

            if (String.IsNullOrEmpty(value) && key == "QnAAuthKey")
            {
                //value = Utils.GetAppSetting("QnASubscriptionKey"); // QnASubscriptionKey for backward compatibility with QnAMaker (Preview)
                value = ConfigurationManager.AppSettings["QnASubscriptionKey"];
            }
            return value;
        }
    }

    // Dialog for QnAMaker Preview service
    [Serializable]
    public class BasicQnAMakerPreviewDialog : QnAMakerDialog
    {
        // Go to https://qnamaker.ai and feed data, train & publish your QnA Knowledgebase.
        // Parameters to QnAMakerService are:
        // Required: subscriptionKey, knowledgebaseId, 
        // Optional: defaultMessage, scoreThreshold[Range 0.0 – 1.0]
        public BasicQnAMakerPreviewDialog() : base(new QnAMakerService(new QnAMakerAttribute(RootDialog.GetSetting("QnAAuthKey"), ConfigurationManager.AppSettings["QnAKnowledgebaseId"], "No good match in FAQ.", 0.5)))
        { }
    }

    // Dialog for QnAMaker GA service
    [Serializable]
    public class BasicQnAMakerDialog : QnAMakerDialog
    {
        // Go to https://qnamaker.ai and feed data, train & publish your QnA Knowledgebase.
        // Parameters to QnAMakerService are:
        // Required: qnaAuthKey, knowledgebaseId, endpointHostName
        // Optional: defaultMessage, scoreThreshold[Range 0.0 – 1.0]
        public BasicQnAMakerDialog() : base(new QnAMakerService(new QnAMakerAttribute(RootDialog.GetSetting("QnAAuthKey"), ConfigurationManager.AppSettings["QnAKnowledgebaseId"], "No good match in FAQ.", 0.5, 5, ConfigurationManager.AppSettings["QnAEndpointHostName"])))
        { }


        protected override async Task DefaultWaitNextMessageAsync(IDialogContext context, IMessageActivity message, QnAMakerResults result)
        {
            if (message.Text.Equals("None of the above."))
            {
                // your code logic
                await context.PostAsync("What kind of thing do you want to ask?");
                //await context.PostAsync("You selected 'None of the above.'");
            }

            await base.DefaultWaitNextMessageAsync(context, message, result);
        }
    }
}