-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathapp.js
65 lines (53 loc) · 1.75 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
require('dotenv-extended').load();
require('./connectorSetup')();
require('./utils.js')();
require('./dialogs/selectLocale')();
require('./dialogs/submitProblem')();
require('./dialogs/submitPhone')();
/*
require('./dialogs/checkProblems.js')();
require('./dialogs/checkMyBill.js')();
*/
// Global actions
bot.endConversationAction('goodbye', 'Goodbye :)', { matches: /^cancel/i });
bot.beginDialogAction('help', '/help', { matches: /^help/i });
bot.beginDialogAction('language', '/selectLocale', { matches: /^language/i });
bot.beginDialogAction('phone', '/submitPhone', { matches: /^phone/i });
bot.beginDialogAction('submitProblem', '/submitProblem');
// Entry point of the bot
bot.dialog('/', [
(session) => {
session.replaceDialog('/promptButtons');
}
]);
bot.dialog('/promptButtons', [
(session, args, next) => {
let choices = session.localizer.gettext(session.preferredLocale(), 'InitialPromptOptions');
builder.Prompts.choice(session, 'InitialPrompt', choices, {'listStyle': 3});
},
(session, results, next) => {
if (results.response) {
let selection = results.response.entity;
// route to corresponding dialogs
switch (selection) {
case 'Submit a problem':
session.replaceDialog('/submitProblem');
break;
case 'Change phone number':
session.reset('/submitPhone');
break;
case 'Change language':
session.reset('/selectLocale');
break;
default:
session.reset('/');
break;
}
}
}
]);
bot.dialog('/help', [
function (session) {
session.endDialog('HelpMessage');
}
]);