Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let server = restify.createServer();
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) }
});
}
} from 'botbuilder-core';
import './css/app.css';
import { WebChatAdapter } from './webChatAdapter';
import { renderWebChat } from 'botframework-webchat';
// Create the custom WebChatAdapter.
const webChatAdapter = new WebChatAdapter();
// Connect our BotFramework-WebChat instance with the DOM.
renderWebChat({
directLine: webChatAdapter.botConnection
}, document.getElementById('webchat')
);
// Instantiate MemoryStorage for use with the ConversationState class.
const memory = new MemoryStorage();
// Add the instantiated storage into ConversationState.
const conversationState = new ConversationState(memory);
// Create a property to keep track of how many messages are received from the user.
const countProperty = conversationState.createProperty('turnCounter');
// Register the business logic of the bot through the WebChatAdapter's processActivity implementation.
webChatAdapter.processActivity(async turnContext => {
// See https://aka.ms/about-bot-activity-message to learn more about the message and other activity types.
if (turnContext.activity.type === ActivityTypes.Message) {
// Read from state.
let count = await countProperty.get(turnContext);
count = count === undefined ? 1 : count;
await turnContext.sendActivity(
`${ count }: You said "${ turnContext.activity.text }"`
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const botbuilder_core_1 = require("botbuilder-core");
const botbuilder_dialogs_1 = require("botbuilder-dialogs");
const { MemoryStorage } = require('botbuilder-core');
const restify = require('restify');
const { default: chalk } = require('chalk');
const { BotFrameworkAdapter } = require('botbuilder');
const { EmulatorAwareBot } = require('./bot');
const memoryStorage = new MemoryStorage();
// Create conversation state with in-memory storage provider.
const conversationState = new botbuilder_core_1.ConversationState(memoryStorage);
const bot = new EmulatorAwareBot(conversationState);
const adapter = new BotFrameworkAdapter({
appId: process.env.MICROSOFT_APP_ID,
appPassword: process.env.MICROSOFT_APP_PASSWORD,
});
if (process.env.NODE_ENV === 'development') {
new botbuilder_dialogs_1.BotDebugger(memoryStorage, adapter);
}
const server = restify.createServer();
server.listen(process.env.PORT, () => {
process.stdout.write(`Bot is listening on port: ${chalk.blue(server.address().port)}`);
});
server.opts('/api/messages', (req, res, next) => {
res.header("Access-Control-Allow-Origin", "*");
import 'skeleton-css/css/normalize.css';
import 'skeleton-css/css/skeleton.css';
import './css/alarmBot.css';
import {Bot, ConversationState, MemoryStorage} from 'botbuilder-core';
import {WebChatAdapter} from "./webChatAdapter";
import {ChatComponent} from "./chatComponent";
import {AlarmRenderer} from "./alarmRenderer";
import {routes} from "./routes";
const webChatAdapter = new WebChatAdapter();
const bot = new Bot(webChatAdapter)
.use(new MemoryStorage(),
new BotStateManager(),
new AlarmRenderer());
ChatComponent.bootstrap(webChatAdapter.getMessagePipelineToBot(), document.querySelector('section'));
// handle activities
bot.onReceive((context) => routes(context));
// FOUC
document.addEventListener('DOMContentLoaded', function () {
requestAnimationFrame(() => document.body.style.visibility = 'visible');
});
import {ConversationState} from "botbuilder-core";
import {BotDebugger} from "botbuilder-dialogs";
const {MemoryStorage} = require('botbuilder-core');
const restify = require('restify');
const {default: chalk} = require('chalk');
const {BotFrameworkAdapter} = require('botbuilder');
const {EmulatorAwareBot} = require('./bot');
const memoryStorage = new MemoryStorage();
// Create conversation state with in-memory storage provider.
const conversationState = new ConversationState(memoryStorage);
const bot = new EmulatorAwareBot(conversationState);
const adapter = new BotFrameworkAdapter({
appId: process.env.MICROSOFT_APP_ID,
appPassword: process.env.MICROSOFT_APP_PASSWORD,
});
if (process.env.NODE_ENV === 'development') {
new BotDebugger(memoryStorage, adapter);
}
const server = restify.createServer();
server.listen(process.env.PORT, () => {
process.stdout.write(`Bot is listening on port: ${chalk.blue(server.address().port)}`);