-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.js
53 lines (38 loc) · 1.34 KB
/
bot.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
46
47
48
49
50
51
52
53
global.builder = require('botbuilder');
const RESPONSES = require('./responses/common.json');
//load in dialogs
var basic = require('./dialogs/basic.js');
function create(connector) {
const bot = new builder.UniversalBot(connector);
//creates a luis recognizer for the / dialog
const intents = new builder.IntentDialog({
recognizers: [
//new builder.LuisRecognizer(process.env.LUIS_MODEL_URL)
]
});
//define reg ex lists here
var schwiftyKeywords = new RegExp(RESPONSES['schwifty.keywords'], "i");
//default dialog
bot.dialog('/', intents
.onBegin(function (session, args, next) {
//create session variables new
session.userData.profile = {};
session.userData.profile.name = "Friend";
next();
})
.matches(schwiftyKeywords, '/getSchwifty')
.matches(/help/, '/help')
.onDefault('/default')
);
//called if no intent is detected
bot.dialog('/default', [
function (session) {
session.endDialog(RESPONSES['default'], session.message.text);
}
]);
bot.dialog('/getSchwifty', basic.dialog);
bot.dialog('/help', RESPONSES['help']);
//need to return the bot for testing
return bot;
}
module.exports = { create }