-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
56 lines (50 loc) · 1.54 KB
/
index.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
var TropoDialer = require('./lib/tropo-dialer'),
TropoSession = require('./lib/tropo-session');
/**
*
* @param {String} number
* @param {Function} callback
* @param {Object} [options]
* @param {Boolean} [options.keepAlive=false]
* @param {Boolean} [options.port=4000]
*/
module.exports = function (number, callback, options) {
var testTropoDialer = new TropoDialer(options),
testTropoSession = new TropoSession(number, {
start: {
question: 'Good morning. Are you awake?',
options: "yes, no, tired",
getNextAction: function (result) {
switch (result.actions.value) {
case 'yes':
return false;
case 'tired':
return 'inspirational';
case 'no' :
default:
return 'notAwake';
break;
}
}
},
notAwake: {
message: 'Then wake up!',
getNextAction: function () {
return false
}
},
inspirational: {
message: "Remember the early bird gets the worm",
getNextAction: function () {
return false
}
}
});
testTropoDialer.pickup(function () {
testTropoDialer.dial(testTropoSession, function () {
console.log('session complete');
callback();
testTropoDialer.hangup(options);
})
});
};