From 7f0c43dd5ffccaba9df62fbf800d4d3e56d570e8 Mon Sep 17 00:00:00 2001 From: Rich Haase Date: Wed, 13 Mar 2024 16:32:26 -0600 Subject: [PATCH] Adds a session attr counting missed utterances --- .../lib/fulfillment-event/processFulfillmentEvent.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lambda/es-proxy-layer/lib/fulfillment-event/processFulfillmentEvent.js b/lambda/es-proxy-layer/lib/fulfillment-event/processFulfillmentEvent.js index ad8f7e1d..e589f224 100644 --- a/lambda/es-proxy-layer/lib/fulfillment-event/processFulfillmentEvent.js +++ b/lambda/es-proxy-layer/lib/fulfillment-event/processFulfillmentEvent.js @@ -226,6 +226,13 @@ async function processFulfillmentEvent(req, res) { res.session.qnabot_qid = _.get(res.result, 'qid', ''); res.session.qnabot_gotanswer = res.got_hits > 0; + // add session attibute to count consecutive missed utterances + if (res.got_hits > 0) { + res.session.no_hits_counter = 0; + } else { + res.session.no_hits_counter = res.session.no_hits_counter ? res.session.no_hits_counter + 1 : 1; + } + const event = { req, res }; return event; }