jazzedge
7/10/2017 - 8:07 AM

Bot Core start-up code

Bot Core start-up code

'use strict';

// 01. Include required files
require('dotenv-extended').load();
var restify = require('restify'); 
var builder = require('botbuilder');
var rp = require('request-promise');
var azure = require('botbuilder-azure');
var Request = require('tedious').Request;
var Connection = require('tedious').Connection;
var cognitiveservices = require('botbuilder-cognitiveservices');
var locationDialog = require('botbuilder-location'); //Bing Maps

// 02. Setup Restify Server
var server = restify.createServer();

// 03. Configure listen for messages
server.listen(process.env.PORT || 3978, function() 
{
   console.log('%s listening to %s', server.name, server.url); 
});

// 04. Create chat bot
var connector = new builder.ChatConnector
 ({
     appId: process.env.MICROSOFT_APP_ID,
     appPassword: process.env.MICROSOFT_APP_PASSWORD
 });

// 05. Listen for messages
server.post('/api/messages', connector.listen());

// 06. Serve static files
server.get(/.*/, restify.plugins.serveStatic({
    directory: __dirname,
    'default': 'index.html'
}));
// 07. Receive messages from the user and respond by echoing each message back (prefixed with 'You said:')
const bot = new builder.UniversalBot(connector, {
    persistConversationData: true
});