How to use the botbuilder-dialogs-adaptive.AdaptiveDialog 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 / 05. beginDialog / lib / index.js View on Github external
console.log(`\nGet Bot Framework Emulator: https://aka.ms/botframework-emulator`);
    console.log(`\nTo talk to your bot, open echobot.bot file in the Emulator.`);
});
// Create bots DialogManager and bind to state storage
const bot = new botbuilder_dialogs_1.DialogManager();
bot.conversationState = new botbuilder_1.ConversationState(new botbuilder_1.MemoryStorage());
bot.userState = new botbuilder_1.UserState(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;
//=================================================================================================
// Rules
//=================================================================================================
dialogs.recognizer = new botbuilder_dialogs_adaptive_1.RegExpRecognizer().addIntent('JokeIntent', /tell .*joke/i);
// Tell the user a joke
dialogs.addRule(new botbuilder_dialogs_adaptive_1.OnIntent('#JokeIntent', [], [
    new botbuilder_dialogs_adaptive_1.BeginDialog('TellJokeDialog')
]));
// Handle unknown intents
dialogs.addRule(new botbuilder_dialogs_adaptive_1.OnUnknownIntent([
    new botbuilder_dialogs_adaptive_1.BeginDialog('AskNameDialog')
]));
//=================================================================================================
// Child Dialogs
//=================================================================================================
github microsoft / botbuilder-js / samples / 03. ifCondition / lib / index.js View on Github external
console.log(`\nGet Bot Framework Emulator: https://aka.ms/botframework-emulator`);
    console.log(`\nTo talk to your bot, open echobot.bot file in the Emulator.`);
});
// Create bots DialogManager and bind to state storage
const bot = new botbuilder_dialogs_1.DialogManager();
bot.conversationState = new botbuilder_1.ConversationState(new botbuilder_1.MemoryStorage());
bot.userState = new botbuilder_1.UserState(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.IfCondition('user.name == null', [
        new botbuilder_dialogs_adaptive_1.TextInput('user.name', `Hi! what's your name?`),
    ]),
    new botbuilder_dialogs_adaptive_1.SendActivity(`Hi {user.name}. It's nice to meet you.`)
]));
//# sourceMappingURL=index.js.map
github microsoft / botbuilder-js / samples / 08. switchCondition / lib / index.js View on Github external
const adapter = new botbuilder_1.BotFrameworkAdapter({
    appId: process.env.microsoftAppID,
    appPassword: process.env.microsoftAppPassword,
});
// Create bots DialogManager and bind to state storage
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 / 06. codeAction / lib / index.js View on Github external
appId: process.env.microsoftAppID,
    appPassword: process.env.microsoftAppPassword,
});
// Create bots DialogManager and bind to state storage
const bot = new botbuilder_dialogs_1.DialogManager();
bot.conversationState = new botbuilder_1.ConversationState(new botbuilder_1.MemoryStorage());
bot.userState = new botbuilder_1.UserState(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;
// Add a default rule for handling incoming messages
dialogs.triggers.push(new botbuilder_dialogs_adaptive_1.OnUnknownIntent([
    new botbuilder_dialogs_adaptive_1.CodeAction(async (dc) => {
        const count = dc.state.getValue('conversation.count') || 0;
        dc.state.setValue('conversation.count', count + 1);
        return await dc.endDialog();
    }),
    new botbuilder_dialogs_adaptive_1.SendActivity('{conversation.count}')
]));
//# sourceMappingURL=index.js.map
github microsoft / botbuilder-js / samples / 05. beginDialog / src / index.ts View on Github external
// Create bots DialogManager and bind to state storage
const bot = new DialogManager();
bot.conversationState = new ConversationState(new MemoryStorage());
bot.userState = new UserState(new 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 AdaptiveDialog();
bot.rootDialog = dialogs;

//=================================================================================================
// Rules
//=================================================================================================

dialogs.recognizer = new RegExpRecognizer().addIntent('JokeIntent', /tell .*joke/i);

// Tell the user a joke
dialogs.addRule(new OnIntent('#JokeIntent', [], [
    new BeginDialog('TellJokeDialog')
]));

// Handle unknown intents
dialogs.addRule(new OnUnknownIntent([
    new BeginDialog('AskNameDialog')
github microsoft / botbuilder-js / samples / 09. sendMap / src / index.ts View on Github external
// Create bots DialogManager and bind to state storage
const bot = new DialogManager();
bot.storage = new 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);
    });
});

const bingMapsKey = 'AlUaNNIoQRik0DZRUj518gEoFeVSxRjo5MTv6JDU1GPX_djqyMFRwIBv89nlfJM6';

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

// Add a default rule for handling incoming messages
dialogs.addRule(new DefaultRule([
    new SetProperty(`conversation.mapPins = ["47.6221,-122.3540;46;1", "47.6205,-122.3493;46;2"]`),
    new SendMap(bingMapsKey, MapType.aerialWithLabels, 'conversation.mapPins')
]));
github microsoft / botbuilder-js / samples / 08. sendChart / lib / index.js View on Github external
const adapter = new botbuilder_1.BotFrameworkAdapter({
    appId: process.env.microsoftAppID,
    appPassword: process.env.microsoftAppPassword,
});
// Create bots DialogManager and bind to state storage
const bot = new lib_1.DialogManager();
bot.storage = 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;
// Add a default rule for handling incoming messages
dialogs.addRule(new botbuilder_dialogs_adaptive_1.DefaultRule([
    new botbuilder_dialogs_adaptive_1.SetProperty(`conversation.chartData.Hello = [1,5,15,10,17]`),
    new botbuilder_dialogs_adaptive_1.SetProperty(`conversation.chartData.World = [0,3,12,13,14]`),
    new botbuilder_dialogs_adaptive_1.SendChart(botbuilder_dialogs_adaptive_1.ChartType.lines, 'conversation.chartData')
]));
//# sourceMappingURL=index.js.map
github microsoft / botbuilder-js / samples / 01. sendActivity / lib / index.js View on Github external
const adapter = new botbuilder_1.BotFrameworkAdapter({
    appId: process.env.microsoftAppID,
    appPassword: process.env.microsoftAppPassword,
});
// Create bots DialogManager and bind to state storage
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.SendActivity('Hello World!')
]));
//# sourceMappingURL=index.js.map
github microsoft / botbuilder-js / samples / 08. switchCondition / src / index.ts View on Github external
});

// Create bots DialogManager and bind to state storage
const bot = new DialogManager();
bot.conversationState = new ConversationState(new 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 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
function createChoiceInputForAllAdaptiveDialogs() {
    const rootDialog = new AdaptiveDialog(AdaptiveDialog.name);
    const choices = [];
    const switchCases = [];
    (resourceExplorer.getResources('.dialog') || []).forEach(resource => {
        if (resource.resourceId !== undefined && resource.resourceId.endsWith('.main.dialog')) {
            let dialogName = path.basename(resource.resourceId, '.main.dialog');
            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),