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

Test with custom root dialog id #76

Closed
cdagli opened this issue Apr 10, 2018 · 2 comments
Closed

Test with custom root dialog id #76

cdagli opened this issue Apr 10, 2018 · 2 comments
Labels

Comments

@cdagli
Copy link

cdagli commented Apr 10, 2018

Hello,

Is it possible to change the root id of the dialogs? In the README examples, '/' is always used as the id

bot.dialog('/',...

I receive the below error if I don't initialize a dialog with '/'

Uncaught Error: Dialog[*:/] not found.

Thanks

@microsoftly
Copy link
Owner

Have you tried navigating through the conversation to get to the desired dialog?

something like this:

const choiceMessage = 'pick a weather dialog or not';
const weatherDialog = 'weather';
const weatherResponse = 'look\'s like there\'ll be rain today';
const nonMatchResponse = 'Sorry, we didn\'t recognize that';

bot.dialog('/', [(session) => {
    Prompts.text(session, choiceMessage );
}, (session, result) => {
    if (result.response === weatherDialog) {
        session.beginDialog(weatherDialog);
    } else {
        session.send(nonMatchResponse);
    }
}]);

bot.dialog(weatherDialog, (session: Session) => {
    session.endDialog(weatherResponse);
});

const weatherMatchTest = new BotTester(bot)
    .sendMessageToBot('hi there!', choiceMessage)
    .sendMessageToBot(weatherDialog, weatherResponse);

const nonMatchTest = new BotTester(bot)
        .sendMessageToBot('hi there!', choiceMessage)
        .sendMessageToBot('this will not match', nonMatchResponse);

return weatherMatchTest
    .runTest()
    .then(() => nonMatchTest.runTest());

@microsoftly
Copy link
Owner

I'm closing this as the solution has been provided with a test that can prove it.

Let me know if you're still having trouble and I can work with you to resolve it or make the API better support your use case

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants