Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

shop.js 2.1 KB

You have to be logged in to leave a comment. Sign In
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
  1. var util = require('util');
  2. var builder = require('botbuilder');
  3. var lib = new builder.Library('shop');
  4. lib.dialog('/', [
  5. function (session) {
  6. // Ask for delivery address using 'address' library
  7. session.beginDialog('address:/',
  8. {
  9. promptMessage: session.gettext('provide_delivery_address', session.message.user.name || session.gettext('default_user_name'))
  10. });
  11. },
  12. function (session, args) {
  13. // Retrieve address, continue to shop
  14. session.dialogData.recipientAddress = args.address;
  15. session.beginDialog('product-selection:/');
  16. },
  17. function (session, args) {
  18. // Retrieve selection, continue to delivery date
  19. session.dialogData.selection = args.selection;
  20. session.beginDialog('delivery:date');
  21. },
  22. function (session, args) {
  23. // Retrieve deliveryDate, continue to details
  24. session.dialogData.deliveryDate = args.deliveryDate;
  25. session.send('confirm_choice', session.dialogData.selection.name, session.dialogData.deliveryDate.toLocaleDateString());
  26. session.beginDialog('details:/');
  27. },
  28. function (session, args) {
  29. // Retrieve details, continue to billing address
  30. session.dialogData.details = args.details;
  31. session.beginDialog('address:billing');
  32. },
  33. function (session, args, next) {
  34. // Retrieve billing address
  35. session.dialogData.billingAddress = args.billingAddress;
  36. next();
  37. },
  38. function (session, args) {
  39. // Continue to checkout
  40. var order = {
  41. selection: session.dialogData.selection,
  42. delivery: {
  43. date: session.dialogData.deliveryDate,
  44. address: session.dialogData.recipientAddress
  45. },
  46. details: session.dialogData.details,
  47. billingAddress: session.dialogData.billingAddress
  48. };
  49. console.log('order', order);
  50. session.beginDialog('checkout:/', { order: order });
  51. }
  52. ]);
  53. // Export createLibrary() function
  54. module.exports.createLibrary = function () {
  55. return lib.clone();
  56. };
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...