Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unknown type of bot/dialog error when extending botbuilder dialog classes #7

Open
SeanSobey opened this issue Jun 20, 2018 · 0 comments
Assignees

Comments

@SeanSobey
Copy link

SeanSobey commented Jun 20, 2018

Example

const unit = require("botbuilder-unit");
const botbuilder = require("botbuilder");

const script = [];
class TestDialog extends botbuilder.SimpleDialog {
    constructor() {
        super(() => { });
    }
}
const dialog = new TestDialog();
unit(dialog, script, {
    title: 'Your first test script',
    reporter: new unit.BeautyLogReporter()
}).then(() => {
    console.log('Script passed');
}, (err) => {
    console.error(err);
});

Results in :

Error: Unknown type of bot/dialog. Error: {"actions":{}}

Looking at botbuilder-unit.js resolveBot function:

function resolveBot(bot) {
  let isWaterfall = ("function" == typeof bot) || Array.isArray(bot);
  if (isWaterfall) {
    let dialog = bot;
    let connector = new TestConnector();
    bot = new builder.UniversalBot(connector);
    bot.dialog('/', dialog);
  } else if (bot instanceof builder.UniversalBot) {
    if ( !bot.connector()) {
      bot.connector('console', new TestConnector());
    }
  } else {
    throw new Error(`Unknown type of bot/dialog. Error: ${JSON.stringify(bot)}`);
  }
  return bot;
}

Could maybe check for instanceof builder.Dialog, eg:

let isWaterfall = ("function" == typeof bot) || Array.isArray(bot);
let isDialog = bot instanceof builder.Dialog;
if (isWaterfall || isDialog) {
 ...

Would you consider a pull request?

@gudwin gudwin self-assigned this Aug 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants