How to use the botbuilder-dialogs-adaptive.SwitchCondition function in botbuilder-dialogs-adaptive

To help you get started, we’ve selected a few botbuilder-dialogs-adaptive examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github microsoft / botbuilder-js / samples / 08. switchCondition / lib / index.js View on Github external
const bot = new botbuilder_dialogs_1.DialogManager();
bot.conversationState = new botbuilder_1.ConversationState(new botbuilder_1.MemoryStorage());
// Listen for incoming activities.
server.post('/api/messages', (req, res) => {
    adapter.processActivity(req, res, async (context) => {
        // Route activity to bot.
        await bot.onTurn(context);
    });
});
// Initialize bots root dialog
const dialogs = new botbuilder_dialogs_adaptive_1.AdaptiveDialog();
bot.rootDialog = dialogs;
// Handle unknown intents
dialogs.triggers.push(new botbuilder_dialogs_adaptive_1.OnUnknownIntent([
    new botbuilder_dialogs_adaptive_1.SetProperty('dialog.age', "'22'"),
    new botbuilder_dialogs_adaptive_1.SwitchCondition('dialog.age', null, [
        new case_1.Case("21", [
            new botbuilder_dialogs_adaptive_1.SendActivity("age is 21!")
        ]),
        new case_1.Case("22", [
            new botbuilder_dialogs_adaptive_1.SendActivity("age is 22!")
        ])
    ])
]));
//# sourceMappingURL=index.js.map
github microsoft / botbuilder-js / samples / 08. switchCondition / src / index.ts View on Github external
// Listen for incoming activities.
server.post('/api/messages', (req, res) => {
    adapter.processActivity(req, res, async (context) => {
        // Route activity to bot.
        await bot.onTurn(context);
    });
});

// Initialize bots root dialog
const dialogs = new AdaptiveDialog();
bot.rootDialog = dialogs;

// Handle unknown intents
dialogs.triggers.push(new OnUnknownIntent([
    new SetProperty('dialog.age', "'22'"),
    new SwitchCondition('dialog.age', null, [
        new Case("21", [
            new SendActivity("age is 21!")
        ]),
        new Case("22", [
            new SendActivity("age is 22!")
        ])
    ])
]));
github microsoft / BotBuilder-Samples / experimental / adaptive-dialog / javascript_nodejs / declarative / 60.adaptive-bot / index.js View on Github external
const subDialog = resourceExplorer.loadType(resource);
            choices.push({value : dialogName});
            switchCases.push(new Case(dialogName, [subDialog]));
        }
    });
    rootDialog.generator = new TemplateEngineLanguageGenerator();
    rootDialog.triggers.push(new OnBeginDialog([
        new ChoiceInput().configure({
            property: new StringExpression('turn.userChoice'),
            prompt: new ActivityTemplate(`Choose a declarative sample to run..`),
            style: new EnumExpression(ListStyle.list),
            choices: new ArrayExpression(choices),
            alwaysPrompt: new BoolExpression(true)
        }),
        new SendActivity("# Running ${turn.userChoice}.main.dialog"),
        new SwitchCondition('turn.userChoice', switchCases),
        new RepeatDialog()
    ]));
    return rootDialog;
}