From 56234cd7ff5f27e758703155ad6e0acd5c118aa8 Mon Sep 17 00:00:00 2001 From: Pasanmahee Date: Thu, 17 Aug 2023 16:31:12 +0530 Subject: [PATCH] Update Entity Extraction Logic in firstEntity Function --- services/receive.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/services/receive.js b/services/receive.js index 9fb7331..ccba3ee 100644 --- a/services/receive.js +++ b/services/receive.js @@ -407,8 +407,14 @@ module.exports = class Receive { setTimeout(() => GraphApi.callSendApi(requestBody), delay); } - firstEntity(nlp, name) { - return nlp && nlp.entities && nlp.entities[name] && nlp.entities[name][0]; + firstEntity(nlp, name) { + if (nlp && nlp.entities && nlp.entities[`wit$${name}:${name}`]) { + return nlp.entities[`wit$${name}:${name}`][0]; + } else if (nlp && nlp.traits && nlp.traits[`wit$${name}`]) { + return nlp.traits[`wit$${name}`][0]; + } else { + return null; + } } handleReportLeadSubmittedEvent() {