-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathintent.js
More file actions
38 lines (35 loc) · 927 Bytes
/
intent.js
File metadata and controls
38 lines (35 loc) · 927 Bytes
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
const _ = require('lodash');
const actions = [
{
intent: 'how_to_connect',
needs: [
{ name: 'router', text: "Ποιο ρούτερ έχεις;"},
{ name: 'service', text: "Ποια υπηρεσία χρησιμοποιείς;"}
]
},
{
intent: 'what_is',
needs: [
{ name: 'service', text: "Για ποια υπηρεσία θες να μάθεις περισσότερα;"}
]
},
{
intent: 'what_number_is',
needs: [
{ name: 'wit/phone_number', text: "Από ποιον αριθμό βλέπετε αυτές τις χρεώσεις;"}
]
}
];
function nextAction({ intent, entities, context }) {
const action = _.find(actions, ['intent', intent]);
if (action) {
context = _.merge(context, entities);
for (let n of action.needs) {
if (!context[n.name])
return n;
}
} else return false;
}
module.exports = {
nextAction
};