-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.js
59 lines (45 loc) · 2.03 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
54
55
56
57
58
59
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
const { ActivityHandler, MessageFactory } = require('botbuilder');
const { QnAMaker } = require('botbuilder-ai');
const DentistScheduler = require('./dentistscheduler');
const IntentRecognizer = require("./intentrecognizer")
class DentaBot extends ActivityHandler {
constructor(configuration, qnaOptions) {
// call the parent constructor
super();
if (!configuration) throw new Error('[QnaMakerBot]: Missing parameter. configuration is required');
// create a QnAMaker connector
this.QnAMaker = new QnAMaker()
// create a DentistScheduler connector
// create a IntentRecognizer connector
this.onMessage(async (context, next) => {
// send user input to QnA Maker and collect the response in a variable
// don't forget to use the 'await' keyword
// send user input to IntentRecognizer and collect the response in a variable
// don't forget 'await'
// determine which service to respond with based on the results from LUIS //
// if(top intent is intentA and confidence greater than 50){
// doSomething();
// await context.sendActivity();
// await next();
// return;
// }
// else {...}
await next();
});
this.onMembersAdded(async (context, next) => {
const membersAdded = context.activity.membersAdded;
//write a custom greeting
const welcomeText = '';
for (let cnt = 0; cnt < membersAdded.length; ++cnt) {
if (membersAdded[cnt].id !== context.activity.recipient.id) {
await context.sendActivity(MessageFactory.text(welcomeText, welcomeText));
}
}
// by calling next() you ensure that the next BotHandler is run.
await next();
});
}
}
module.exports.DentaBot = DentaBot;