From cdec9175a5f3adddb673ef1998d131f831dce077 Mon Sep 17 00:00:00 2001 From: Amruth-Vamshi Date: Thu, 14 Sep 2023 17:38:00 +0530 Subject: [PATCH] added generic response for conversation starter. --- src/common/en.json | 3 ++- src/xstate/prompt/prompt.gaurds.ts | 4 +++- src/xstate/prompt/prompt.machine.ts | 10 ++++++++++ src/xstate/prompt/prompt.service.ts | 4 ++-- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/common/en.json b/src/common/en.json index 8825bb7..f7c2967 100644 --- a/src/common/en.json +++ b/src/common/en.json @@ -8,5 +8,6 @@ "message.invalid_question":"Sorry, for such query, I am still working. You may try some other query (queries). I hope shortly I would be able to address all your concerns. ", "label.popUpTitle.short": "Enter your Aadhaar Number / Registration Number / Mobile Number", "label.popUpTitle2.short": "Enter your last 4 digits of Aadhaar", - "label.popUpTitle3.short": "Enter your One Time Password." + "label.popUpTitle3.short": "Enter your One Time Password.", + "message.convoStarter":"Dear Beneficiary, Please ask question related to your PM Kisan account." } diff --git a/src/xstate/prompt/prompt.gaurds.ts b/src/xstate/prompt/prompt.gaurds.ts index 8bca6d6..1c3bae5 100644 --- a/src/xstate/prompt/prompt.gaurds.ts +++ b/src/xstate/prompt/prompt.gaurds.ts @@ -20,6 +20,8 @@ export const promptGuards = { ifOTPHasBeenVerified: (context,_) => context.isOTPVerified, - ifInvalidClassifier: (_,event) => event.data == "invalid" + ifInvalidClassifier: (_,event) => event.data == "invalid", + + ifConvoStarterOrEnder: (_,event) => event.data == "convo_starter" || event.data == "convo_ender" } \ No newline at end of file diff --git a/src/xstate/prompt/prompt.machine.ts b/src/xstate/prompt/prompt.machine.ts index 8dfc706..cf0d0d5 100644 --- a/src/xstate/prompt/prompt.machine.ts +++ b/src/xstate/prompt/prompt.machine.ts @@ -866,6 +866,16 @@ export const botFlowMachine3:any = invoke: { src: "questionClassifier", onDone: [ + { + cond: "ifConvoStarterOrEnder", + target: "getUserQuestion", + actions: [ + assign({ + response: () => engMessage["message.convoStarter"], + type:"pause" + }) + ] + }, { cond: "ifInvalidClassifier", target: "getUserQuestion", diff --git a/src/xstate/prompt/prompt.service.ts b/src/xstate/prompt/prompt.service.ts index 7d2a1d0..9917543 100644 --- a/src/xstate/prompt/prompt.service.ts +++ b/src/xstate/prompt/prompt.service.ts @@ -40,8 +40,8 @@ export class PromptServices { if (response == "LABEL_2") return "invalid" if (response == "LABEL_1") return "payment" if (response == "LABEL_0") return "payment" - if (response == "LABEL_3") return "invalid" - if (response == "LABEL_4") return "invalid" + if (response == "LABEL_3") return "convo_starter" + if (response == "LABEL_4") return "convo_ender" return response; } catch (error){ return Promise.reject(error)