-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
156 lines (88 loc) · 3.58 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
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
// VIDEO LINK FOR DEMO: https://www.youtube.com/watch?v=O7j-Re3R454&feature=youtu.be&hd=1
var builder = require('botbuilder');
var restify = require('restify');
var cognitiveservices=require('botbuilder-cognitiveservices');
// Setting up the Restify Server
var server = restify.createServer();
server.listen(process.env.port || process.env.PORT || 4041, function () {
console.log('%s listening to %s', server.name, server.url);
});
var bot;
// Create chat bot and listen to messages
var connector = new builder.ChatConnector({
appId:'YOUR ID', //create your app id and app password log on to microsoft bot framework
appPassword: 'YOUR APP PASSWORD'
});
server.post('/api/messages', connector.listen());
var DialogLabels = {
Tracking_status:'Tracking_status', //labels
Information_about_the_price:'Information_about_the_price',
Support:'Support'
};
var bot;
bot = new builder.UniversalBot(connector,[
function (session) {
builder.Prompts.text(session,"Hello Humans !! I am D-Fast :) Tell me your name?"); }, //waterfall modeL
function(session,result,next) {
session.send("hello %s", result.response);
next();
},
function(session,next,result) {
builder.Prompts.choice(session,"Are you looking for -- 1. Tracking the package -- 2. Info about the cost of shipping a package -- 3. Support(asking Queries like package lost/lost my tracking ID etc). e.g.-- TYPE 1 or Tracking_status ",[DialogLabels.Tracking_status,DialogLabels.Information_about_the_price,DialogLabels.Support],
{
maxRetries: 9,
retryPrompt: 'Not a valid option :(.Please choose within given options above. For e.g.- Type 1 or Tracking-status for tracking info .okk :) '
});},
function (session, result) {
if (!result.response) {
//try so manyy
session.send('You tried so many times dear customer:( But don\'t worry, I\'m here :)!');
return session.endDialog();
}
var select=result.response.entity;
switch (select) {
case DialogLabels.Tracking_status:
return session.beginDialog('Tracking_status');
case DialogLabels.Support:
return session.beginDialog('Support');
case DialogLabels.Information_about_the_price:
return session.beginDialog('Information_about_the_price');
}}
]);
bot.dialog('Tracking_status',require('./Tracking'));
bot.dialog('Information_about_the_price',require('./Info'));
/**
* Created by Shubham Jaiswal on 7/15/2017.
*/
var restify = require('restify');
var builder = require('botbuilder');
var cognitiveservices=require('botbuilder-cognitiveservices');
//var cognitiveservices = require('../../lib/botbuilder-cognitiveservices'
var recognizer=new cognitiveservices.QnAMakerRecognizer({
knowledgeBaseId:'deb8bda7-d7a9-4e33-95f8-351d6c5b48cf',
subscriptionKey:'542f08ab1f2d4873aaeac72a3230a55b'});
var BasicQnAMakerDialog= new cognitiveservices.QnAMakerDialog(
{
recognizers:[recognizer],
defaultMessage:'I did not get you.Please rephrase it',
qnaThreshold:0.3
});
bot.dialog('new',BasicQnAMakerDialog);
bot.dialog("Support",[function(session,result) {
builder.Prompts.text(session,'Please ask me your queries?? ');
},
function(session,result,next) {
if (result.response != 'exit') {
session.beginDialog('new');
}
else
{
session.endDialog("Byeee!!!");
}},
function(session) {
//if (result.response != 'exit') {
bot.dialog('new');
}
]);
module.exports.bot=bot;
//var info=require('/info')