When there is a multiprompt present, instead of adding buttons to go further I would like to add them directly into my card.
I have the qnaid's of the questions, can I get the answer just with the id?
When there is a multiprompt present, instead of adding buttons to go further I would like to add them directly into my card.
I have the qnaid's of the questions, can I get the answer just with the id?
I think the proper way to do this is to build the qnaState from the answer, grab the text from the prompt, and then make your new query with those parameters.
So first for reference, here is the QnA maker call I'm making.
if (qnAcontext == null) {
qnAcontext = {
PreviousQnaId: 0,
PreviousUserQuery: null
}
}
const qnaResult = await request({
url: url,
method: 'POST',
headers: headers,
json: {
question: query,
top: 3,
context: qnAcontext
}
});
I have this code in a helper function that I call from my qna dialog but I think the location isn't important. You can see I've set a "default" qnAcontext. This is what you will be updating to make your prompt-based call.
From the result, you can get the prompt buttons via
var prompts = null;
if(qnaResult[0].context != null){
prompts = qnaResult[0].context.prompts;
}
I've not done this before so I'm not exactly sure where you can get the text attribute from, but I'm assuming it's at qnaResults[0].context.prompts[0].text
. You'll need to take a look at the prompts object to confirm. You also need to create the new state, and grab the first part of the answer. These things can be done via
var qnAcontext = {
PreviousQnaId: qnaResult[0].id,
PreviousUserQuery: activity.text
}
answerText = qnaResult[0].answer;
Now just make another call using the new qnAContext and the prompt text as the query. Technically, if you don't have the follow up question set as context only, you don't have to mess with the qnAcontext. You should just be able to use the prompt text as the next query and the answer should come up. If the answer is context only, you'll need to pass the qnAcontext object, though.
Edit: For a direct answer to your question about querying with qnaId directly, see the link added below by Kyle Delaney.