The Data Daily

Microsoft Bot Framework: Forms Dialog and Dynamic Options - DZone Big Data

Last updated: 10-11-2018

Read original article here

Microsoft Bot Framework: Forms Dialog and Dynamic Options - DZone Big Data

I've already written a series about Microsoft Bot Framework. If you missed it, you can check it out here. Today, I want to go deeper and explain a really good feature: form dialog. This feature is used to create a form and allows our bot to ask questions field-by-field until the user completes the form.

In particular, I want to explain how to add dynamic options to our font so let dive into the description right away.

Let's suppose we have a form and we want our bot to ask for each property in our form to the user in order to complete it. First, we need to define our form. In my case, I'm using the same code that I have in my working example. As always, the working example is available here.

As you can see in the code above, we just define a new class. The properties of this class are going to be used by our Bot to complete the form. Then we need to define a static method to return an iForm. As you can see below, this method creates an instance of the class  and then just returns the method . In this,  its going to define which field we want to ask the user about. To do that, we are going to use the method . Then, using the  method, we will define the behavior for our Bot after populating all of the requested fields. As you can see, this is a good way to guide our user through a form.

I've seen a lot of examples where the user can choose one of many options but those options are always defined using an Enum. In my case, I want to define the options dynamically so to do that our field needs to be an instance of . This new object has a method  as you can see in the code above, which is used in my example to get the list of places and return a list to the user to select one option.

As you can see, creating a form using the Microsoft Bot Framework is really easy — and adding dynamic options to a field is even easier.

For more details of Microsoft Bot Framework, you can use this link.

If you found this post useful, please don't forget to press the like button and share it. If you are in doubt, don't hesitate to ask a question and, as always, thank you for reading.

Read the rest of this article here