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]) {