Bot Framework V4 多轮提示功能问题 QnaMaker

Bot Framework V4 Multi-turn prompt Feature issue QnaMaker

我有一个直接连接到 QnaMaker 的机器人,正在测试有关如何响应用户的新提示功能,下面是 QnaMaker 的示例 Qna

1) 
q) How to get New York Printer details(QnAID: 13)
a) details are below NY73889-B0

2)
q) How to get Dallas printer details (QnAID: 14)
a) details are below DL093883-B1

3)
q) printer location 
a) please chose from the 2 options below
   Dallas(QnAID: 13)  New York(QnAID: 14)    (Prompts)
4)
q)Dallas
a) Dallas is a beautiful city

5)
q)New York
a) City of lights

问题: 用户提出问题 "printer location" 并得到提示纽约和达拉斯的响应。然后当用户 select 其中一个位置说达拉斯时,理想情况下它应该用答案

来响应

2) q) 如何获取 Dallas 打印机详细信息 (QnAID: 14) a) 详细信息在 DL093883-B1 下面,因为我们有连接到问题 4 的提示,并且我们使用旧状态,它具有 selected 选项 QnaID for dallas.. 但是相反,它给出了下面的答案,因为它只与用户响应的 dallas 提示文本相匹配,而不考虑旧状态,感谢任何帮助

4) q)达拉斯 a) 达拉斯是一座美丽的城市

protected override async Task<(object newState, IEnumerable<Activity> output, object result)> ProcessAsync(object oldState, Activity inputActivity)
{
    Activity outputActivity = null;
    QnABotState newState = null;
    var query = inputActivity.Text; ;


    //Step 4) We Build the json based on the value selected user so we make a call to the Qna Maker using the response from the user on the button click and the previous state
    //here we check if there was a prompt  from the previous question and update the state to send to the bot for response based on the option selected
    if (((QnAPrompting.Models.QnABotState)oldState) != null)
    {
        for (int i = 0; i < ((QnABotState)oldState).PreviousPromptValues.Length; i++)
        {
            if (((QnABotState)oldState).PreviousPromptValues[i].DisplayText == query)
            {
                ((QnABotState)oldState).qnaId = ((QnABotState)oldState).PreviousPromptValues[i].QnaId;
                ((QnABotState)oldState).question = query;
            }
        }
    } //Step5). when we get the response from the user after the choosing an option from the prompt, it queries the qnamaker and filters based on the old state as well
    //Step1). we get the prompts based on the question asked for the first time the old state is empty
    var qnaResult = await _qnaService.QueryQnAServiceAsync(query, (QnABotState)oldState);
    var qnaAnswer = qnaResult[0].Answer;
    var prompts = qnaResult[0].Context?.Prompts;

    if (prompts == null || prompts.Length < 1)
    {

        if (((QnAPrompting.Models.QnABotState)oldState) != null)
        {
            if (((QnAPrompting.Models.QnABotState)oldState).IsPreviousPrompt)
            {
                string method = "/knowledgebases/{0}/{1}/qna/";
                var method_with_id = String.Format(method, "KBID", "prod");
                var uri = "https://westus.api.cognitive.microsoft.com" + "/qnamaker/v4.0" + method_with_id;
                Console.WriteLine("Calling " + uri + ".");
                var response = await Get(uri);
            }
        }
        outputActivity = MessageFactory.Text(qnaAnswer);
    }
    else //Step 2.)prompt parameters are stored in the state
    {

        ContextValues ctx = new ContextValues();
        ctx.PreviousQnaId = qnaResult[0].Id;
        ctx.PreviousUserQuery = query;
        //store here in azure table
        newState = new QnABotState
        {
            question = string.Empty,
            top=10,
            userId = "Default",
            context = ctx,
            PreviousPromptValues = prompts,
        };

        outputActivity = CardHelper.GetHeroCard(qnaAnswer, prompts);
    }
    //Step 3) Prompt is displayed to the user
    return (newState, new Activity[] { outputActivity }, null);
}

我从源代码重新下载了代码here。仅修改机器人设置我 运行 代码并且它按预期工作。正如 Kyle 指出的那样,问题是我修改了 QueryQnAServiceAsync 并导致了这个问题。现在一切正常。