forked from microsoft/BotBuilder-Samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
RootDialog.cs
41 lines (33 loc) · 1.2 KB
/
RootDialog.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
namespace TestBot
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Helpers;
using Microsoft.Bot.Builder.Dialogs;
using Microsoft.Bot.Builder.Dialogs.Internals;
using Microsoft.Bot.Connector;
[Serializable]
public class RootDialog : IDialog<object>
{
private readonly IEnumerable<string> validKeywords;
public RootDialog(IEnumerable<string> validKeywords)
{
this.validKeywords = validKeywords;
}
public async Task StartAsync(IDialogContext context)
{
context.Wait(this.MessageReceivedAsync);
}
public async virtual Task MessageReceivedAsync(IDialogContext context, IAwaitable<IMessageActivity> result)
{
var message = await result;
// not recognized command
var reply = context.MakeMessage();
reply.Text = $"Sorry {message.From.Name}, I cannot understand your message, the valid keywords are: {string.Join(", ", this.validKeywords.Select(kw => $"**{kw}**"))}";
await context.PostAsync(reply);
context.Wait(this.MessageReceivedAsync);
}
}
}