Articles → MICROSOFT BOT FRAMEWORK → Formflow In Microsoft Bot Framework

Formflow In Microsoft Bot Framework






Purpose





Example




  1. Name
  2. Age
  3. Marital Status




  1. Create a new class "FormFlowDemo".
  2. Write the following code.
  3. using Microsoft.Bot.Builder.FormFlow;
    using System;
    
    namespace Bot_Application1.Dialogs {
    	public enum MaritalStatus {
    		Married,
    		Unmarried,
    		Single
    	}
    
    	[Serializable]
    	public class FormFlowDemo {
    		public string name;
    		public int age;
    		public MaritalStatus ? maritalStatus;
    
    		public static IForm < FormFlowDemo > GetForm() {
    			return new FormBuilder < FormFlowDemo > ().Message("Welcome to support chat system. Please enter the following information to serve you better").Build();
    		}
    	}
    }


  4. Inside the "MessagesController.cs", create a function "MakeDialog".
  5. private IDialog < Dialogs.FormFlowDemo > MakeDialog() {
    	return Chain.From(() = >FormDialog.FromForm(Dialogs.FormFlowDemo.GetForm));
    }


  6. Call the "MakeDialog" method inside the "Post" method.
  7. Picture showing calling the MakeDialog class inside the MessageController
    Click to Enlarge



Output




Picture showing the chatbot asking the name and age from the user
Click to Enlarge



Picture showing the chatbot asking the marital status from the user
Click to Enlarge





Picture showing the card asking the user to change the input
Click to Enlarge


Status And Help




Picture showing the output of status command in chatbot
Click to Enlarge



Picture showing the output of help command in chatbot
Click to Enlarge


Posted By  -  Karan Gupta
 
Posted On  -  Monday, October 12, 2020

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250