forked from microsoft/BotBuilder-Samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdelivery.js
32 lines (28 loc) · 854 Bytes
/
delivery.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
var builder = require('botbuilder');
var Today = 'today';
var Tomorrow = 'tomorrow';
var lib = new builder.Library('delivery');
lib.dialog('date', [
function (session, args, next) {
builder.Prompts.choice(session, 'choose_delivery_date', [
session.gettext(Today),
session.gettext(Tomorrow)
]);
},
function (session, args) {
var deliveryDate = args.response.entity === session.gettext(Today) ? new Date() : new Date().addDays(1);
session.endDialogWithResult({
deliveryDate: deliveryDate
});
}
]);
// Helpers
Date.prototype.addDays = function (days) {
var date = new Date(this.valueOf());
date.setDate(date.getDate() + days);
return date;
};
// Export createLibrary() function
module.exports.createLibrary = function () {
return lib.clone();
};