How to use the botframework-webchat/built/App.App function in botframework-webchat

To help you get started, we’ve selected a few botframework-webchat 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 / echobot-es6-botframework-webchat / src / app.js View on Github external
//     containerName: ''
// });

// To use Azure Cosmos DB Storage to store memory, you can the CosmosDbStorage class from `botbuilder-azure`
// const memory = new CosmosDbStorage({
//     serviceEndpoint: '',
//     authKey: '',
//     databaseId: '',
//     collectionId: ''
// });

// Create the custom WebChatAdapter and add the ConversationState middleware
const webChatAdapter = new WebChatAdapter()

// Connect our BotFramework-WebChat App instance with the DOM
App({
    user: { id: "Me!" },
    bot: { id: "bot" },
    botConnection: webChatAdapter.botConnection,
}, document.getElementById('bot'));

// Add the instatiated storage into state middleware
const convoState = new ConversationState(memory);
const userState = new UserState(memory);
webChatAdapter.use(new BotStateSet(convoState, userState));

// Register the business logic of the bot through the WebChatAdapter's processActivity implementation.
webChatAdapter.processActivity(async (context) => {
    const state = convoState.get(context);
    state.bump = state.bump ? state.bump + 1 : 1;
    await context.sendActivity(`${state.bump}: You said, "${context.activity.text}"`);
});
github microsoft / botbuilder-js / samples / alarmbot-es6-botframework-webchat / src / app.js View on Github external
import {Bot, BotStateManager, MemoryStorage} from "botbuilder";
import 'botframework-webchat/botchat.css';
import {App} from 'botframework-webchat/built/App';
import {WebChatAdapter} from './webChatAdapter';
import {AlarmRenderer} from "./alarmRenderer";
import {routes} from './routes';
import {AlarmsListComponent} from "./alarmsListComponent";

const webChatAdapter = new WebChatAdapter();

const bot = new Bot(webChatAdapter)
    .use(new MemoryStorage(),
        new BotStateManager(),
        new AlarmRenderer());
App({
    user: {id: "Me!"},
    bot: {id: "bot"},
    botConnection: webChatAdapter.botConnection,
}, document.getElementById('bot'));

AlarmsListComponent.bootstrap(webChatAdapter.botConnection.activity$, document.querySelector('.alarms-container'));
// handle activities
bot.onReceive((context) => routes(context));

// FOUC
document.addEventListener('DOMContentLoaded', function () {
    requestAnimationFrame(() => document.body.style.visibility = 'visible');
});