From f1c1ed12329ca660e9f88c6280165450fc4b0b06 Mon Sep 17 00:00:00 2001 From: Bob Strahan Date: Thu, 13 Oct 2022 01:57:24 +0000 Subject: [PATCH] fixes #506 - bot prompts 'What is the question?' when using ElicitResponse --- lambda/fulfillment/lib/middleware/lex.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/lambda/fulfillment/lib/middleware/lex.js b/lambda/fulfillment/lib/middleware/lex.js index a7de2c2f9..79ea4efe1 100644 --- a/lambda/fulfillment/lib/middleware/lex.js +++ b/lambda/fulfillment/lib/middleware/lex.js @@ -28,7 +28,18 @@ function isConnectClientChat(req){ } function isElicitResponse(request, response){ - return _.get(response,'result.elicitResponse.responsebot_hook', undefined) !== undefined || _.get(request,'session.qnabotcontext.specialtyBot' ,undefined) !== undefined; + let result = false; + const qnabotcontextJSON = _.get(response,'session.qnabotcontext'); + if (qnabotcontextJSON) { + const qnabotcontext = JSON.parse(qnabotcontextJSON); + if (_.get(qnabotcontext,'elicitResponse.responsebot')) { + result = true; + } + if (_.get(qnabotcontext,'specialtyBot')) { + result = true; + } + } + return result; } function trapIgnoreWords(req, transcript) { @@ -395,9 +406,7 @@ function getV2ElicitTemplate(request, response){ sessionState: { sessionAttributes:_.get(response,'session',{}), dialogAction:{ - type:'ElicitSlot', - slotToElicit: 'qnaslot' - }, + type:'ElicitIntent' }, intent: { name: 'QnaIntent', },