Articles → MICROSOFT BOT FRAMEWORK → Prompt dialog in Microsoft Bot framework

Prompt dialog in Microsoft Bot framework






Purpose





Example
















using Microsoft.Bot.Builder.Dialogs;
using Microsoft.Bot.Connector;
using System;
using System.Threading.Tasks;

namespace Bot_Application1.Dialogs { [Serializable]
	public class PromptDemo: IDialog < object > {
		public async Task StartAsync(IDialogContext context) {
			await context.PostAsync("Welcome to gyansangrah.com.");
			context.Wait(GetNameAsync);
		}

		private Task GetNameAsync(IDialogContext context, IAwaitable < IMessageActivity > activity) {
			PromptDialog.Text(
			context: context, resume: ResumeGetName, prompt: "Please enter your name", retry: "Please enter the name again");

			return Task.CompletedTask;
		}

		private async Task ResumeGetName(IDialogContext context, IAwaitable < string > result) {
			string name = await result;
			await context.PostAsync($ "Thank you {name}");
		}
	}
}



Output


Picture showing the output of prompt dialog 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