Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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);
});
});
});
}
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
});
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);
});
});
});
}
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
});
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);
});
});
});
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);
});
});
});
}
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);
});
});
});
}
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);
});
});
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());
}
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());
}