forked from jcocchi/HannahHackathon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
45 lines (38 loc) · 1.7 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
require('dotenv').config()
const restify = require('restify')
const builder = require('botbuilder')
// Setup Restify Server
const server = restify.createServer()
server.listen(process.env.port || process.env.PORT || 3978, function () {
console.log('%s listening to %s', server.name, server.url)
})
// Create chat bot
const connector = new builder.ChatConnector({
appId: process.env.APP_ID,
appPassword: process.env.APP_PASS
})
const bot = new builder.UniversalBot(connector)
server.post('/api/messages', connector.listen())
const model = `https://api.projectoxford.ai/luis/v1/application?id=${process.env.LUIS_ID}&subscription-key=${process.env.LUIS_KEY}&verbose=true`
bot.recognizer(new builder.LuisRecognizer(model))
bot.dialog('/', [
(session, args, next) => {
session.send('Hello there!')
session.endDialog('I can help you get an Azure Code, find resources, or connect you with our Microsoft team! What would you like help with?')
}
])
bot.library(require('./app/dialogs/greeting').createLibrary())
bot.library(require('./app/dialogs/teamInfo').createLibrary())
bot.library(require('./app/dialogs/techHelp').createLibrary())
bot.library(require('./app/dialogs/azureCode').createLibrary())
bot.library(require('./app/dialogs/negativeComment').createLibrary())
bot.library(require('./app/dialogs/profanity').createLibrary())
bot.library(require('./app/dialogs/azureCodeError').createLibrary())
bot.library(require('./app/dialogs/endConvo').createLibrary())
bot.library(require('./app/dialogs/botHelp').createLibrary())
bot.library(require('./app/dialogs/none').createLibrary())
// TODO add server proxy for ifame
server.get(/\/?.*/, restify.plugins.serveStatic({
directory: __dirname,
default: 'index.html'
}))