From 4e207e22da9b274b236512029bed89268839d2b8 Mon Sep 17 00:00:00 2001 From: khanh Date: Sun, 7 Jul 2024 03:38:35 +0700 Subject: [PATCH] updated action goto --- actions/Goto.js | 13 +++++++++---- actions/Main.js | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/actions/Goto.js b/actions/Goto.js index 00400d8..4ec41cf 100644 --- a/actions/Goto.js +++ b/actions/Goto.js @@ -1,5 +1,7 @@ const { ComponentDialog, WaterfallDialog } = require('botbuilder-dialogs'); const { GO_TO } = require('../Constant'); +const { endConversation } = require('../utils/utils'); +const { ERROR_MESSAGE } = process.env; const GOTOACTION_WATERFALL = 'GOTOACTION_WATERFALL'; @@ -8,15 +10,18 @@ class GotoAction extends ComponentDialog { super(GO_TO); this.dialog = dialog; this.addDialog( - new WaterfallDialog(GOTOACTION_WATERFALL, [ - this.goto.bind(this), - ]) + new WaterfallDialog(GOTOACTION_WATERFALL, [this.goto.bind(this)]) ); this.initialDialogId = GOTOACTION_WATERFALL; } async goto(step) { - const { gotoId } = step.step._info.options; + const { gotoId } = step._info.options; + + if (!gotoId) { + return await endConversation(step, ERROR_MESSAGE); + } + return await step.endDialog({ actionId: gotoId }); } } diff --git a/actions/Main.js b/actions/Main.js index f5379c1..da0f225 100644 --- a/actions/Main.js +++ b/actions/Main.js @@ -195,7 +195,7 @@ class MainDialog extends ComponentDialog { 'sub-flow': SUB_FLOW, 'check-variables': CHECK_VARIABLE, 'send-mail': SEND_MAIL, - 'goto"': GO_TO + 'goto': GO_TO }; if (!actions[action]) {