Articles → MICROSOFT BOT FRAMEWORK → Dialog chain in Microsoft Bot Framework

Dialog chain in Microsoft Bot Framework






What is a dialog chain?















Example








using Microsoft.Bot.Builder.Dialogs;
using System.Linq;
using System.Text.RegularExpressions;

namespace Bot_Application1.Dialogs {
	public class MyDialogChain {
		public static readonly IDialog < string > dialog = Chain.PostToChain().Select(x = >x.Text).Switch(
		Chain.Case(
		new Regex("^hi", RegexOptions.IgnoreCase), (context, text) = >Chain.Return("Good day!!!").PostToUser()), 
    Chain.Case(
		new Regex("^how are you", RegexOptions.IgnoreCase), (context, text) = >Chain.Return("I am fine, thanks for asking. How may I help you?").PostToUser()), 
    Chain.Default < string, IDialog < string >> ((context, text) = >Chain.Return("I didn't get your question").PostToUser())).Unwrap();
	}
}




Picture showing calling the MyDialogChain class inside the MessageController

Click to Enlarge


Output


Picture showing the output of dialog chain in Microsoft bot framework

Click to Enlarge


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

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250