Skip to content

Commit

Permalink
Merge pull request #507 from aws-solutions/fix/elicit-response-slot-p…
Browse files Browse the repository at this point in the history
…rompt-bug

fixes #506 - bot prompts 'What is the question?' when using ElicitResponse
  • Loading branch information
tabdunabi authored Oct 24, 2022
2 parents ffb0829 + f1c1ed1 commit 8b0df4e
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions lambda/fulfillment/lib/middleware/lex.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -395,9 +406,7 @@ function getV2ElicitTemplate(request, response){
sessionState: {
sessionAttributes:_.get(response,'session',{}),
dialogAction:{
type:'ElicitSlot',
slotToElicit: 'qnaslot'
},
type:'ElicitIntent' },
intent: {
name: 'QnaIntent',
},
Expand Down

0 comments on commit 8b0df4e

Please sign in to comment.