Naeem Shaikh
Naeem Shaikh

Reputation: 15715

replaceDialog() where the dialog is defind using dialog.matches

I have integrated LUIS with my chatbot, and almost all of my dialogs are defined using dialog.matches(). The problem is that some dialogs need to be redirected to other dialogs, but replaceDialog or beginDialog doesnt seem to be working for dialogs which are defined using dialog.matches. Example: consider following dialog

options.dialog.matches('startActivity', [
        function(session) {
})

how do i manually invoke it from some other dialog? session.replaceDialog('startActivity') throws an error.

Error: Dialog[*:startActivity] not found.
    at Session.replaceDialog (D:\insight\ms-bot\src\api\node_modules\botbuilder\
lib\Session.js:146:19)
    at Array.options.dialog.matches.regEx (D:\insight\ms-bot\src\api\dialogs\mor
tgage\mortgage-check-account-balance.dialog.js:7:26)
    at Object.waterfallAction [as mortgageCheckBalance] (D:\insight\ms-bot\src\a
pi\node_modules\botbuilder\lib\dialogs\DialogAction.js:130:25)
    at IntentDialog.invokeIntent (D:\insight\ms-bot\src\api\node_modules\botbuil
der\lib\dialogs\IntentDialog.js:264:44)

Refer this issue on githib

Upvotes: 0

Views: 231

Answers (1)

Lars
Lars

Reputation: 10573

The string you pass into matches() is the Intent to match not a dialog name. You need to break your waterfall out as a separate dialog so:

options.dialog.matches('startActivity', [
     function (session) {
           session.beginDialog('/startActivity');
     }
]);

bot.dialog('/startActivity', [
     function (session) { },
     function (session, results) {
          session.replaceDialog('/startActivity');
     }
]);

Upvotes: 1

Related Questions