forked from cyrillebenoit/conversationMaster
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuttons.js
41 lines (41 loc) · 1.21 KB
/
buttons.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
const buttonText = {
//"string that has to be included in Watson output text" : button array index in buttons defined below.
"offres Plus, Pro, et Ultra": 0,
"par oui ou non": 1,
"Voulez-vous ": 1,
"Voulez vous": 1,
"voulez vous": 1,
"voulez-vous ": 1,
"Avez-vous ": 1,
"avez-vous ": 1,
"Avez vous ": 1,
"avez vous ": 1,
"est-ce bien": 1,
"Tout est bon pour vous": 1,
"vous préférez peut-être télé": 1,
"Souhaitez-vous": 1,
"Vous pouvez modifier votre offre": 2,
"Nous proposons deux bouquets": 3
}
const buttons = [
['Plus', 'Pro', 'Ultra'],
['Oui', 'Non'],
['Adresse', 'Identité', 'Offre', 'Options TV', 'Moyen de paiement'],
['Canal+', 'CanalSat', 'Les deux', 'Aucun']
]
module.exports = {
/**
* Returns button array if necessary.
* The rules to react are set in the static arrays buttonText and buttons.
* @param {string} text text from Watson
* @return {Object or boolean} buttons or false if not needed
*/
sendWithButtons: function(text) {
if (Object.keys(buttonText).length !== 0) {
for (button in buttonText) {
if (text.indexOf(button) !== -1) return buttons[buttonText[button]];
}
}
return false;
}
}