|
13 | 13 | /// [EntityRecommendation.Entity]: @ref Microsoft.Bot.Builder.Luis.EntityRecommendation.Entity
|
14 | 14 | /// [LuisDialog]: @ref Microsoft.Bot.Builder.Dialogs.LuisDialog
|
15 | 15 | /// [AllowDefault]: @ref Advanced.TemplateBaseAttribute.AllowDefault
|
16 |
| - /// [ChoiceCase]: @ref Advanvced.TemplateBaseAttribute.ChoiceCase |
| 16 | + /// [ChoiceCase]: @ref Advanced.TemplateBaseAttribute.ChoiceCase |
17 | 17 | /// [ChoiceLastSeparator]: @ref Advanced.TemplateBaseAttribute.ChoiceLastSeparator
|
18 |
| - /// [ChoiceSeparator]: @ref Advanced.TemplateBaseAttribtue.ChoiceSeparator |
| 18 | + /// [ChoiceSeparator]: @ref Advanced.TemplateBaseAttribute.ChoiceSeparator |
19 | 19 | /// [ChoiceFormat]: @ref Advanced.TemplateBaseAttribute.ChoiceFormat
|
20 | 20 | /// [ChoiceParens]: @ref Advanced.TemplateBaseAttribute.ChoiceParens
|
21 | 21 | /// [ChoiceStyle]: @ref Advanced.TemplateBaseAttribute.ChoiceStyle
|
|
112 | 112 | /// * Back: Go back to the previous question.
|
113 | 113 | /// * Help: Show the kinds of responses you can enter.
|
114 | 114 | /// * Quit: Quit the form without completing it.
|
115 |
| - /// * Reset: Start over filling in the form. (With defaults of your previous entries.) |
| 115 | + /// * Reset: Start over filling in the form. (With defaults from your previous entries.) |
116 | 116 | /// * Status: Show your progress in filling in the form so far.
|
117 | 117 | /// * You can switch to another field by entering its name. (Sandwich, Length, Bread, Cheese, Toppings, and Sauce).
|
118 | 118 | /// ~~~
|
|
423 | 423 | /// * Back: Go back to the previous question.
|
424 | 424 | /// * Help: Show the kinds of responses you can enter.
|
425 | 425 | /// * Quit: Quit the form without completing it.
|
426 |
| - /// * Reset: Start over filling in the form. (With defaults of your previous entries.) |
| 426 | + /// * Reset: Start over filling in the form. (With defaults from your previous entries.) |
427 | 427 | /// * Status: Show your progress in filling in the form so far.
|
428 | 428 | /// * You can switch to another field by entering its name. (Sandwich, Length, Bread, Cheese, Sauces, and Toppings).
|
429 | 429 | /// ~~~
|
|
564 | 564 | /// For sandwich toppings you have selected Avocado, Banana Peppers, Cucumbers, Green Bell Peppers, Lettuce, Olives, Pickles, Red Onion, Spinach, and Tomatoes.
|
565 | 565 | /// ~~~
|
566 | 566 | ///
|
567 |
| - /// \subsection ControlFlow Using the Form Builder |
| 567 | + /// \subsection controlFlow Using the Form Builder |
568 | 568 | /// So far we have improved your dialog via attributes and business logic. There is
|
569 | 569 | /// another way to improve your dialog and that is through the FormBuilder. The FormBuilder
|
570 | 570 | /// allows more fine-grained control over the steps in your conversation and lets you put in messages
|
|
573 | 573 | /// is explicit navigation.) Here is a more complex usage of FormBuilder:
|
574 | 574 | /// \dontinclude AnnotatedSandwichBot/AnnotatedSandwich.cs
|
575 | 575 | /// \skip static
|
576 |
| - /// \until return |
| 576 | + /// \until .Build |
577 | 577 | /// \until }
|
578 | 578 | ///
|
579 |
| - /// The steps this defines are: |
580 |
| - /// * Show the welcome message |
581 |
| - /// * Fill in SandwichOrder.Sandwich |
| 579 | + /// This looks complex, but that is because of the addition of advanced features like validation and dynamically defined fields. |
| 580 | + /// (See \ref dynamicFields for more information.) |
| 581 | + /// The main structure is all about defining the default step order. Here are the steps: |
| 582 | + /// * Show the welcome message. |
| 583 | + /// * Fill in SandwichOrder.Sandwich |
582 | 584 | /// * Fill in SandwichOrder.Length
|
583 | 585 | /// * Fill in SandwichOrder.Bread
|
584 | 586 | /// * Fill in SandwichOrder.Cheese
|
585 | 587 | /// * Fill in SandwichOrder.Toppings
|
586 |
| - /// * Show a message confirming the selected toppings. |
| 588 | + /// * Show a message confirming the selected toppings. |
| 589 | + /// * Fill in SandwichOrder.Sauces |
| 590 | + /// * Dynamically defined field for SandwichOrder.Specials. (See \ref dynamicFields for more information.) |
| 591 | + /// * Dynamically defined confirmation for the cost |
587 | 592 | /// * Fill in SandwichOrder.DeliveryAddress and verify the resulting string. If it does not start with a number we return a message.
|
588 | 593 | /// * Fill in SandwichOrder.DeliveryTime with a custom prompt.
|
589 | 594 | /// * Confirm the order.
|
590 | 595 | /// * Add any remaining fields in the order they are defined in your class. (If this was left out, those steps to fill in those fields would not be included.)
|
591 |
| - /// * Show a final message thanking them. |
| 596 | + /// * Show a final thank you message. |
| 597 | + /// * Define an OnCompletionAsync handler to process the order. |
592 | 598 | ///
|
593 | 599 | /// In the SandwichOrder.DeliveryTime prompt and the confirmation message you can see an instance of
|
594 | 600 | /// the \ref patterns where pattern elements like {Length} are filled in from your C# class
|
595 | 601 | /// before the string is shown to the user.
|
596 | 602 | ///
|
| 603 | + /// \subsection dynamicFields Dynamically Defined Fields, Confirmations and Messages |
597 | 604 | /// FormBuilder also allows you to do other more advanced things like dynamically switch on
|
598 | 605 | /// and off parts of your form based on the state of your object or dynamically define fields
|
599 | 606 | /// rather than drive them off a C# class.
|
600 | 607 | ///
|
| 608 | + /// In order to define a dynamic field, you can implement Advanced.IField yourself, |
| 609 | + /// but it is easier to make use of the Advanced.FieldReflector class. Imagine we would like to |
| 610 | + /// create some specials for free drinks and cookies but only for foot-long sandwiches. |
| 611 | + /// The first step for using Advanced.FieldReflector is to define |
| 612 | + /// the underlying field that will contain your dynamic value, like this: |
| 613 | + /// \dontinclude AnnotatedSandwichBot/AnnotatedSandwich.cs |
| 614 | + /// \skip Sauces |
| 615 | + /// \skip Optional |
| 616 | + /// \until Specials |
| 617 | + /// |
| 618 | + /// We can apply normal attributes to this field like [Optional] to mark the field as allowing a no preference choice and by changing the template |
| 619 | + /// value for TemplateUsage.NoPreference. |
| 620 | + /// |
| 621 | + /// Now we need to add the dynamic part to the FormBuilder like this: |
| 622 | + /// \dontinclude AnnotatedSandwichBot/AnnotatedSandwich.cs |
| 623 | + /// \skip nameof(Specials) |
| 624 | + /// \until })) |
| 625 | + /// |
| 626 | + /// There are a couple of pieces here: |
| 627 | + /// * Advanced.Field.SetType sets the type of the field--in this case null which means enumeration. |
| 628 | + /// * Advanced.Field.SetActive provides a delegate that enables the field only when the length is a foot long. |
| 629 | + /// * Advanced.Field.SetDefine provides an async delegate for defining the field. The delegate is passed the current state object and also the Advanced.Field that is being dynamically defined. |
| 630 | + /// The delegate uses the fluent methods found on the field to dynamically define values. In this case we define values as strings and supply the descriptions and terms for the value. |
| 631 | + /// |
| 632 | + /// Messages and confirmations can also be defined dynamically. Messages and confirmations only run when the prior steps are inactive |
| 633 | + /// or are completed. This is a confirmation that computes the cost of the sandwich: |
| 634 | + /// \dontinclude AnnotatedSandwichBot/AnnotatedSandwich.cs |
| 635 | + /// \skip Confirm |
| 636 | + /// \until }) |
| 637 | + /// |
| 638 | + /// \subsection quitExceptions Handling Quit and Exceptions |
| 639 | + /// When the user types 'quit' or there is an exception while filling in a form using FormDialog it is useful to be able |
| 640 | + /// to know what step the 'quit' or exception happened, the state of the form and and what steps were successfully completed. |
| 641 | + /// All of these are passed back through the FormCanceledException<T> class. Here is an example of how to catch the exception and send |
| 642 | + /// a message after either: |
| 643 | + /// * Successfully processing the order. |
| 644 | + /// * When the user quit. |
| 645 | + /// * When there is an exception. |
| 646 | + /// \dontinclude AnnotatedSandwichBot/Controllers/MessagesController.cs |
| 647 | + /// \skip MakeRootDialog |
| 648 | + /// \until }); |
| 649 | + /// \until } |
| 650 | + /// |
| 651 | + /// \subsection finalBot Final Sandwich Bot |
601 | 652 | /// Here is the final SandwichOrder with attributes, business logic and a more complex form.
|
602 | 653 | /// \include AnnotatedSandwichBot/AnnotatedSandwich.cs
|
603 | 654 | ///
|
|
623 | 674 | /// 15. Veggie
|
624 | 675 | /// > 2
|
625 | 676 | /// What size of sandwich do you want? (1. Six Inch, 2. Foot Long)
|
626 |
| - /// > 1 |
| 677 | + /// > 2 |
627 | 678 | /// What kind of bread would you like on your sandwich?
|
628 | 679 | /// 1. Nine Grain Wheat
|
629 | 680 | /// 2. Nine Grain Honey Oat
|
630 | 681 | /// 3. Italian
|
631 | 682 | /// 4. Italian Herbs And Cheese
|
632 | 683 | /// 5. Flatbread
|
633 | 684 | /// > nine grain
|
634 |
| - /// By "nine grain" bread did you mean(1. Nine Grain Honey Oat, 2. Nine Grain Wheat) |
| 685 | + /// By "nine grain" bread did you mean (1. Nine Grain Honey Oat, 2. Nine Grain Wheat) |
635 | 686 | /// > 1
|
636 | 687 | /// What kind of cheese would you like on your sandwich? (current choice: No Preference)
|
637 | 688 | /// 1. American
|
|
654 | 705 | /// > everything but jalapenos
|
655 | 706 | /// For sandwich toppings you have selected Avocado, Banana Peppers, Cucumbers, Green Bell Peppers, Lettuce, Olives, Pickles, Red Onion, Spinach, and Tomatoes.
|
656 | 707 | ///
|
657 |
| - /// Please select one or more sauces(current choice: No Preference) |
| 708 | + /// Please select one or more sauces (current choice: No Preference) |
658 | 709 | /// 1. Honey Mustard
|
659 | 710 | /// 2. Light Mayonnaise
|
660 | 711 | /// 3. Regular Mayonnaise
|
|
665 | 716 | /// 8. Sweet Onion
|
666 | 717 | /// 9. Vinegar
|
667 | 718 | /// >
|
| 719 | + /// What kind of specials would you like on your sandwich? (current choice: None) |
| 720 | + /// 1. Free cookie |
| 721 | + /// 2. Free large drink |
| 722 | + /// > 1 |
| 723 | + /// Total for your sandwich is $6.50 is that ok? |
| 724 | + /// > y |
668 | 725 | /// Please enter delivery address
|
669 | 726 | /// > 123 State Street
|
670 | 727 | /// What time do you want your sandwich delivered? (current choice: No Preference)
|
671 |
| - /// > 4:30 |
672 |
| - /// Do you want to order your Six Inch Black Forest Ham on Nine Grain Honey Oat bread with Pepperjack, Avocado, Banana Peppers, Cucumbers, Green Bell Peppers, Lettuce, Olives, Pickles, Red Onion, Spinach, and Tomatoes to be sent to 123 State Street at 4:30 PM? |
| 728 | + /// > 4:30pm |
| 729 | + /// Do you want to order your Foot Long Black Forest Ham on Nine Grain Honey Oat bread with Pepperjack, Avocado, Banana Peppers, Cucumbers, Green Bell Peppers, Lettuce, Olives, Pickles, Red Onion, Spinach, and Tomatoes to be sent to 123 State Street at 4:30 PM? |
673 | 730 | /// > y
|
674 | 731 | /// Please enter a number between 1.0 and 5.0 for your experience today(current choice: No Preference)
|
675 | 732 | /// > 5
|
676 | 733 | /// Thanks for ordering a sandwich!
|
| 734 | + /// Processed your order! |
677 | 735 | /// ~~~
|
678 | 736 | ///
|
679 | 737 | /// \section initialState Passing in Initial Form State and Entities
|
|
0 commit comments