-
Notifications
You must be signed in to change notification settings - Fork 0
/
dialogHelpDesk.js
77 lines (63 loc) · 2.19 KB
/
dialogHelpDesk.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
var builder = require('botbuilder');
var snow = require('./snow')
var cards = require('./helperCard');
var luis = require('./luis')
var apps = ['outlook', 'vpn'];
module.exports = (bot) => {
bot.dialog('/helpDesk',[
(session, args,next) => {
var args = args || none;
var entities = args.entities || [];
var intents = args.intents || [];
if (!entities || entities.length == 0) {
session.replaceDialog('askForIssue');
}else {
session.replaceDialog('extractInfo',entities);
}
},
]);
bot.dialog('askForIssue', [
(session) => {
builder.Prompts.text(session,"What is the issue that you are facing?")
},
(session,results,next) => {
var intents;
var entities;
luis.recognize(results.response, next, function(err){
next(results.response);
})
},
(session,args,next)=>{
entities = args.entities || none;
session.replaceDialog('extractInfo', entities)
}
]);
bot.dialog('extractInfo',[
(session, args, next) => {
//args is an array of Entities/Issues mentioned by user.
session.dialogData.identifiedApps = args || {};
if (args.length == 0) {
session.endDialog();
}else {
entity = session.dialogData.identifiedApps.shift();
console.log(entity.entity);
if (apps.indexOf(entity.entity.toLowerCase()) > -1) {
session.send("Let's discuss " + entity.entity);
session.beginDialog('dialog-' + entity.entity);
}else {
session.send("Sorry, I could not find anything for " + entity.entity);
session.send("Please try again! ");
}
}
},
(session,next) => {
session.replaceDialog('extractInfo',session.dialogData.identifiedApps);
}
]);
};
getDialog = (listOfDialogs)=>{
return listOfDialogs[Math.floor(Math.random()*listOfDialogs.length)];
}
var none = function(){
return
}