-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathapp.js
More file actions
63 lines (51 loc) · 2 KB
/
Copy pathapp.js
File metadata and controls
63 lines (51 loc) · 2 KB
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
54
55
56
57
58
59
60
61
62
var restify = require('restify');
var builder = require('botbuilder');
var istorage= require('./lib/IStorageClient');
var azure = require('./lib/AzureBotStorage.js');
var conf = require('./config/conf.js');
//=========================================================
// Bot Setup
//=========================================================
// Setup Restify Server
var server = restify.createServer();
server.listen(process.env.port || process.env.PORT || 3980, function () {
console.log('%s listening to %s', server.name, server.url);
});
// Create chat bot
var connector = new builder.ChatConnector({
appId:conf.appId,
appPassword:conf.appPass
});
// Listen for messages from users
server.post('/api/messages', connector.listen());
var Rasarecognizer = require('./lib/RasaRecognizer.js');
RasarecognizerObj=new Rasarecognizer();
var dialog = new builder.IntentDialog({ recognizers: [RasarecognizerObj] });//pass here Rasa Recognizer instead of luis
var intents = new builder.IntentDialog();
//Store session and context into mnongodb
var docDbClient = new istorage.IStorageClient();
var tableStorage = new azure.AzureBotStorage({ gzipData: false },docDbClient);
var bot = new builder.UniversalBot(connector)//.set('storage', tableStorage);//set your storage here
bot.use(builder.Middleware.dialogVersion({ version: 3.0, resetCommand: /^reset/i }));
bot.dialog('/',dialog);
dialog.matches('welcomeDialog','welcomeDialog');
bot.dialog('welcomeDialog', [
function (session, args, next) {
var username=session.message.user.name;
session.send("hello %s",username);
session.endConversation();
}
]);
dialog.matches('pleasantries','pleasantries');
bot.dialog('pleasantries', [
function (session, args, next) {
session.send("i am fine");
session.endConversation();
}
]);
dialog.onDefault([
function (session, args, next) {
session.send("sorry i didn't understand command,you are in default dialog");
session.endConversation();
}
])