How to use the botbuilder-core.BotStateManager function in botbuilder-core

To help you get started, we’ve selected a few botbuilder-core 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 / prompts-es6 / app.js View on Github external
server.listen(process.env.port || process.env.PORT || 3978, function () {
    console.log(`${server.name} listening to ${server.url}`);
});

// Create adapter and listen to our servers '/api/messages' route.
const botFrameworkAdapter = new BotFrameworkAdapter({ 
    appId: process.env.MICROSOFT_APP_ID, 
    appPassword: process.env.MICROSOFT_APP_PASSWORD 
});
server.post('/api/messages', botFrameworkAdapter.listen());

// Setup bot
const bot = new botbuilder.Bot(botFrameworkAdapter)
    .use(new botbuilder.ConsoleLogger())
    .use(new botbuilder.MemoryStorage())
    .use(new botbuilder.BotStateManager())
    .onReceive((context) => {
        if (context.request.type === botbuilder.ActivityTypes.message) {
            // Check to see if the user said cancel or menu
            const utterance = (context.request.text || '').trim();
            if (/^cancel/i.test(utterance)) {
                endDemo(context);
            } else if (/^menu/i.test(utterance)) {
                menu(context);
            } else {
                // Route incoming message to active prompt
                return prompts.Prompt.routeTo(context).then((handled) => {
                    // If no active prompt then start the task
                    if (!handled) { startDemo(context) }
                });
            }
        }
github microsoft / botbuilder-js / samples / rivescript-ts / lib / app.js View on Github external
const botbuilder_services_1 = require("botbuilder-services");
const botbuilder_rivescript_1 = require("botbuilder-rivescript");
const restify = require("restify");
const path = require("path");
// Create server
let server = restify.createServer();
server.listen(process.env.port || process.env.PORT || 3978, function () {
    console.log('%s listening to %s', server.name, server.url);
});
// Create connector
const botFrameworkAdapter = new botbuilder_services_1.BotFrameworkAdapter({ appId: process.env.MICROSOFT_APP_ID, appPassword: process.env.MICROSOFT_APP_PASSWORD });
server.post('/api/messages', botFrameworkAdapter.listen());
// Initialize bot
const bot = new botbuilder_core_1.Bot(botFrameworkAdapter)
    .use(new botbuilder_node_1.FileStorage())
    .use(new botbuilder_core_1.BotStateManager())
    .use(new botbuilder_rivescript_1.RiveScriptReceiver(path.join(__dirname, "../rive/complex.rive")));
// END OF LINE
github microsoft / botbuilder-js / samples / rivescript-es6 / app.js View on Github external
server.listen(process.env.port || process.env.PORT || 3978, function () {
    console.log(`${server.name} listing to ${server.url}`);
});

// init adapter
const botFrameworkAdapter = new BotFrameworkAdapter({ 
    appId: process.env.MICROSOFT_APP_ID, 
    appPassword: process.env.MICROSOFT_APP_PASSWORD 
});
// bind adapter to messages route
server.post('/api/messages', botFrameworkAdapter.listen());

// init bot
const bot = new botbuilder.Bot(botFrameworkAdapter)
    .use(new FileStorage())
    .use(new botbuilder.BotStateManager())
    .use(new rive.RiveScriptReceiver(path.join(__dirname, "./rive/complex.rive")));


// END OF LINE