Skip to content

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

Description

@SeanSobey

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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions