How to use the botbuilder-dialogs-declarative.TypeLoader 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-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-js / samples / 51.declarative / src / index.ts View on Github external
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-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-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());
    }

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