Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

RootDialog.cs 1.2 KB

You have to be logged in to leave a comment. Sign In
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
  1. namespace TestBot
  2. {
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Threading.Tasks;
  7. using Helpers;
  8. using Microsoft.Bot.Builder.Dialogs;
  9. using Microsoft.Bot.Builder.Dialogs.Internals;
  10. using Microsoft.Bot.Connector;
  11. [Serializable]
  12. public class RootDialog : IDialog<object>
  13. {
  14. private readonly IEnumerable<string> validKeywords;
  15. public RootDialog(IEnumerable<string> validKeywords)
  16. {
  17. this.validKeywords = validKeywords;
  18. }
  19. public async Task StartAsync(IDialogContext context)
  20. {
  21. context.Wait(this.MessageReceivedAsync);
  22. }
  23. public async virtual Task MessageReceivedAsync(IDialogContext context, IAwaitable<IMessageActivity> result)
  24. {
  25. var message = await result;
  26. // not recognized command
  27. var reply = context.MakeMessage();
  28. reply.Text = $"Sorry {message.From.Name}, I cannot understand your message, the valid keywords are: {string.Join(", ", this.validKeywords.Select(kw => $"**{kw}**"))}";
  29. await context.PostAsync(reply);
  30. context.Wait(this.MessageReceivedAsync);
  31. }
  32. }
  33. }
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...