forked from microsoft/BotBuilder-Samples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
55 lines (48 loc) · 1.74 KB
/
app.js
File metadata and controls
55 lines (48 loc) · 1.74 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
var builder = require('botbuilder');
var restify = require('restify');
// Setup Restify Server
var server = restify.createServer();
server.listen(process.env.port || process.env.PORT || 3978, function () {
console.log('%s listening to %s', server.name, server.url);
});
// Create chat bot
var connector = new builder.ChatConnector({
appId: process.env.MICROSOFT_APP_ID,
appPassword: process.env.MICROSOFT_APP_PASSWORD
});
const ChangePasswordOption = 'Change Password';
const ResetPasswordOption = 'Reset Password';
var bot = new builder.UniversalBot(connector, [
(session) => {
builder.Prompts.choice(session,
'What do yo want to do today?',
[ChangePasswordOption, ResetPasswordOption],
{ listStyle: builder.ListStyle.button });
},
(session, result) => {
if (result.response) {
switch (result.response.entity) {
case ChangePasswordOption:
session.send('This functionality is not yet implemented! Try resetting your password.');
session.reset();
break;
case ResetPasswordOption:
session.beginDialog('resetPassword:/');
break;
}
} else {
session.send(`I am sorry but I didn't understand that. I need you to select one of the options below`);
}
},
(session, result) => {
if (result.resume) {
session.send('You identity was not verified and your password cannot be reset');
session.reset();
}
}
]);
//Sub-Dialogs
bot.library(require('./dialogs/reset-password'));
//Validators
bot.library(require('./validators'));
server.post('/api/messages', connector.listen());