1

I'm working on adding follow up prompts to QnAMaker responses.

var answers = await qnaService.GetAnswersAsync(stepContext.Context, null, null);
var prompts = answers[0].Context?.morecodehere() <---  Context not defined. 

answers is resolved as QueryResult[]

The documentation, samples, and SO question indicate that there is a Context property on the QueryResult object; however, my project's QnAResult from the Virtual Assistant Template does not.

I'd like to be able to follow the samples's way of accessing follow-up prompts using adaptive cards.

My question is whether or not I have something outdated or if it is more likely that I have a configuration issue. Could this be as simple as creating a new QueryResult model to use?

Sample from Microsoft's sample library:

...

 var query = inputActivity.Text;           
 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)
 {
    outputActivity = MessageFactory.Text(qnaAnswer);
 }

...

QueryResult Class from Metadata Locally

namespace Microsoft.Bot.Builder.AI.QnA
{
    public class QueryResult
    {
        public QueryResult();

        [JsonProperty("questions")]
        public string[] Questions { get; set; }

        [JsonProperty("answer")]
        public string Answer { get; set; }

        [JsonProperty("score")]
        public float Score { get; set; }

        [JsonProperty(PropertyName = "metadata")]
        public Metadata[] Metadata { get; set; }

        [JsonProperty(PropertyName = "source")]
        public string Source { get; set; }

        [JsonProperty(PropertyName = "id")]
        public int Id { get; set; }
    }
}

Sample from Faq.qna Json

 "qnaDocuments": [    
     {
      "id": 46,
      "answer": "Answer Text [Redacted Link](https://link)\n.",
      "source": "sourcefile.docx",
      "questions": [
        "Sample question text"
      ],
      "metadata": [],
      "alternateQuestions": "",
      "alternateQuestionClusters": [],
      "context": {
        "isContextOnly": false,
        "prompts": [
          {
            "displayOrder": 0,
            "qnaId": 51,
            "qna": {
              "id": 51,
              "answer": "[Redacted Link](https://linkhere)",
              "source": "Editorial",
              "questions": [
                "More Information",
                "Troubleshooting Information"
              ],
              "metadata": [],
              "alternateQuestions": "",
              "alternateQuestionClusters": [],
              "context": {
                "isContextOnly": true,
                "prompts": []
              }
            },
            "displayText": "More Information"
          }
        ]
      }
    },
...

Package and SDK Versions

Roy
  • 69
  • 7

0 Answers0