From 6e71a80e46f33d1686dd758a7a69cc548c2cf512 Mon Sep 17 00:00:00 2001 From: Arsh Kashyap Date: Thu, 9 Jun 2022 15:51:34 +0530 Subject: [PATCH] Pass qnaId in value attribute of multiturn prompts --- libraries/botbuilder-ai/src/qnaCardBuilder.ts | 6 ++++-- libraries/botbuilder-ai/src/qnaMakerDialog.ts | 12 ++++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/libraries/botbuilder-ai/src/qnaCardBuilder.ts b/libraries/botbuilder-ai/src/qnaCardBuilder.ts index 67ff00f2cc..9a66a72f62 100644 --- a/libraries/botbuilder-ai/src/qnaCardBuilder.ts +++ b/libraries/botbuilder-ai/src/qnaCardBuilder.ts @@ -76,9 +76,11 @@ export class QnACardBuilder { result.context?.prompts?.forEach((prompt) => { buttonList.push({ - value: prompt.displayText, - type: 'imBack', + value: prompt.qnaId, + type: 'messageBack', title: prompt.displayText, + text: prompt.displayText, + displayText: prompt.displayText, }); }); diff --git a/libraries/botbuilder-ai/src/qnaMakerDialog.ts b/libraries/botbuilder-ai/src/qnaMakerDialog.ts index 765a58d9d6..48844a4953 100644 --- a/libraries/botbuilder-ai/src/qnaMakerDialog.ts +++ b/libraries/botbuilder-ai/src/qnaMakerDialog.ts @@ -749,8 +749,16 @@ export class QnAMakerDialog extends WaterfallDialog implements QnAMakerDialogCon } private resetOptions(dc: DialogContext, dialogOptions: QnAMakerDialogOptions) { - // Resetting context and QnAId - dialogOptions.qnaMakerOptions.qnaId = 0; + // Resetting QnAId if not present in value + const qnaIdFromContext = dc.context.activity.value; + + if (qnaIdFromContext != null) { + dialogOptions.qnaMakerOptions.qnaId = qnaIdFromContext; + } else { + dialogOptions.qnaMakerOptions.qnaId = 0; + } + + // Resetting context dialogOptions.qnaMakerOptions.context = { previousQnAId: 0, previousUserQuery: '' }; // Check if previous context is present, if yes then put it with the query