How to use the botbuilder-dialogs-declarative.ResourceExplorer function in botbuilder-dialogs-declarative

To help you get started, we’ve selected a few botbuilder-dialogs-declarative 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 / 51.declarative / lib / index.js View on Github external
readPackageJson(path, async function (err, json) {
        if (err) {
            console.log(err);
            return;
        }
        // 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());
        // bind rootDialog
        let loader = new botbuilder_dialogs_declarative_1.TypeLoader();
        if (resourcesFolder) {
            let resourceExplorer = new botbuilder_dialogs_declarative_1.ResourceExplorer();
            // resourceExplorer.registerDirectory(`./libraries/botbuilder-dialogs-declarative/tests/resources`);
            resourceExplorer.addFolder(`./libraries/botbuilder-dialogs-declarative/tests/resources`);
            loader = new botbuilder_dialogs_declarative_1.TypeLoader(null, resourceExplorer);
        }
        const dialog = await loader.load(json);
        bot.rootDialog = dialog;
        // Listen for incoming activities.
        server.post('/api/messages', (req, res) => {
            adapter.processActivity(req, res, async (context) => {
                // Route activity to bot.
                await bot.onTurn(context);
            });
        });
    });
}
github microsoft / BotBuilder-Samples / experimental / adaptive-dialog / javascript_nodejs / 20.echo-bot-declarative / index.js View on Github external
const restify = require('restify');
const { ResourceExplorer } = require('botbuilder-dialogs-declarative');
const { AdaptiveDialogComponentRegistration, LanguageGeneratorMiddleWare } = require('botbuilder-dialogs-adaptive');
const { DialogManager } = require('botbuilder-dialogs');
const { MemoryStorage, UserState, ConversationState } = require('botbuilder');

// Import required bot services.
// See https://aka.ms/bot-services to learn more about the different parts of a bot.
const { BotFrameworkAdapter } = require('botbuilder');

// Import required bot configuration.
const ENV_FILE = path.join(__dirname, '.env');
dotenv.config({ path: ENV_FILE });

// Set up resource explorer
const resourceExplorer = new ResourceExplorer().addFolder(__dirname, true, true);
resourceExplorer.addComponent(new AdaptiveDialogComponentRegistration(resourceExplorer));

// Create HTTP server
const server = restify.createServer();
server.listen(process.env.port || process.env.PORT || 3978, () => {
    console.log(`\n${ server.name } listening to ${ server.url }`);
    console.log('\nGet Bot Framework Emulator: https://aka.ms/botframework-emulator');
    console.log('\nTo talk to your bot, open the emulator select "Open Bot"');
});

// Create adapter.
// See https://aka.ms/about-bot-adapter to learn more about how bots work.
const adapter = new BotFrameworkAdapter({
    appId: process.env.MicrosoftAppId,
    appPassword: process.env.MicrosoftAppPassword
});
github microsoft / botbuilder-js / samples / 51.declarative / src / index.ts View on Github external
async function (err, json) {
            if (err) {
                console.log(err);
                return;
            }

            // Create bots DialogManager and bind to state storage
            const bot = new DialogManager();
            bot.conversationState = new ConversationState(new MemoryStorage());
            bot.userState = new UserState(new MemoryStorage());

            // bind rootDialog
            let loader = new TypeLoader();
            if (resourcesFolder) {
                let resourceExplorer = new ResourceExplorer();
                // resourceExplorer.registerDirectory(`./libraries/botbuilder-dialogs-declarative/tests/resources`);
                resourceExplorer.addFolder(`./libraries/botbuilder-dialogs-declarative/tests/resources`);
                loader = new TypeLoader(null, resourceExplorer);
            }
            const dialog = await loader.load(json);
            bot.rootDialog = dialog as Dialog;

            // Listen for incoming activities.
            server.post('/api/messages', (req, res) => {
                adapter.processActivity(req, res, async (context) => {
                    // Route activity to bot.
                    await bot.onTurn(context);
                });
            });
    });
}
github microsoft / BotBuilder-Samples / experimental / adaptive-dialog / javascript_nodejs / declarative / 60.adaptive-bot / index.js View on Github external
const { TemplateEngineLanguageGenerator, ActivityTemplate, AdaptiveDialog, AdaptiveDialogComponentRegistration, LanguageGeneratorMiddleWare, ChoiceInput, SendActivity, SwitchCondition, RepeatDialog, OnBeginDialog } = require('botbuilder-dialogs-adaptive');
const { DialogManager, ListStyle } = require('botbuilder-dialogs');
const { MemoryStorage, UserState, ConversationState } = require('botbuilder');
const { Case } = require('botbuilder-dialogs-adaptive/lib/actions/case');
const { StringExpression, ArrayExpression, BoolExpression, EnumExpression } = require('adaptive-expressions');

// Import required bot services.
// See https://aka.ms/bot-services to learn more about the different parts of a bot.
const { BotFrameworkAdapter } = require('botbuilder');

// Import required bot configuration.
const ENV_FILE = path.join(__dirname, '.env');
dotenv.config({ path: ENV_FILE });

// Set up resource explorer
const resourceExplorer = new ResourceExplorer().addFolder(path.join(__dirname, './dialogs'), true, true);
resourceExplorer.addComponent(new AdaptiveDialogComponentRegistration(resourceExplorer));

// Create HTTP server
const server = restify.createServer();
server.listen(process.env.port || process.env.PORT || 3978, () => {
    console.log(`\n${ server.name } listening to ${ server.url }`);
    console.log('\nGet Bot Framework Emulator: https://aka.ms/botframework-emulator');
    console.log('\nTo talk to your bot, open the emulator select "Open Bot"');
});

// Create adapter.
// See https://aka.ms/about-bot-adapter to learn more about how bots work.
const adapter = new BotFrameworkAdapter({
    appId: process.env.MicrosoftAppId,
    appPassword: process.env.MicrosoftAppPassword
});
github microsoft / botbuilder-js / libraries / botbuilder-dialogs-adaptive / src / testing / testRunner.ts View on Github external
constructor(private resourcePath: string) {
        const typeFactory = new TypeFactory();
        const resourceExplorer = new ResourceExplorer();
        resourceExplorer.addFolder(this.resourcePath);

        this.typeLoader = new TypeLoader(typeFactory, resourceExplorer);
        this.typeLoader.addComponent(new AdaptiveComponentRegistration());
        this.typeLoader.addComponent(new AdaptiveTestComponentRegistration());
    }
github microsoft / botbuilder-js / libraries / botbuilder-dialogs-adaptive / src / languageGenerationMiddleware.ts View on Github external
public constructor(resourceExpolrer: ResourceExplorer = undefined, defaultLg: string = undefined) {
        this._resourceExplorer = resourceExpolrer? resourceExpolrer : new ResourceExplorer();
        this._defaultLg = defaultLg? defaultLg : 'main.lg';
    }

botbuilder-dialogs-declarative

Declarative library for the Microsoft BotBuilder dialog system.

MIT
Latest version published 3 months ago

Package Health Score

90 / 100
Full package analysis