Articles → MICROSOFT BOT FRAMEWORK → Create Your First Dialog In Microsoft Bot Framework
Create Your First Dialog In Microsoft Bot Framework
What Is Dialog?
How To Create Your Own Dialog?
- Create a new class "WelcomeDialog".
- Implement the "IDialog" interface.
- Implement the "Async" method.
using Microsoft.Bot.Builder.Dialogs;
using System;
using System.Threading.Tasks;
namespace Bot_Application1.Dialogs {
[Serializable]
public class WelcomeDialog: IDialog < object > {
public Task StartAsync(IDialogContext context) {
context.Wait(PerformActionAsync);
return Task.CompletedTask;
}
private async Task PerformActionAsync(IDialogContext context, IAwaitable < object > result) {
var activity = await result as Microsoft.Bot.Connector.Activity;
if (activity.Text == "hi") {
await context.PostAsync("Hi How are you");
}
else await context.PostAsync("Please say it again");
}
}
}
- Call the "WelcomeDialog" class inside the "MessageController" class.
Click to Enlarge
Output
Click to Enlarge