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

IntroDialog.cs 2.3 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
  1. namespace JobListingBot.Dialogs
  2. {
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Threading.Tasks;
  7. using Microsoft.Bot.Builder.Dialogs;
  8. using Microsoft.Bot.Builder.Internals.Fibers;
  9. using Microsoft.Bot.Connector;
  10. using Search.Dialogs;
  11. using Search.Models;
  12. using Search.Services;
  13. [Serializable]
  14. public class IntroDialog : IDialog<object>
  15. {
  16. protected readonly SearchQueryBuilder QueryBuilder = new SearchQueryBuilder();
  17. private readonly ISearchClient searchClient;
  18. public IntroDialog(ISearchClient searchClient)
  19. {
  20. SetField.NotNull(out this.searchClient, nameof(searchClient), searchClient);
  21. }
  22. public Task StartAsync(IDialogContext context)
  23. {
  24. context.Wait(this.SelectTitle);
  25. return Task.CompletedTask;
  26. }
  27. public Task SelectTitle(IDialogContext context, IAwaitable<IMessageActivity> input)
  28. {
  29. context.Call(
  30. new SearchRefineDialog(
  31. this.searchClient,
  32. "business_title",
  33. this.QueryBuilder,
  34. prompt: "Hi! To get started, what kind of position are you looking for?"),
  35. this.StartSearchDialog);
  36. return Task.CompletedTask;
  37. }
  38. public async Task StartSearchDialog(IDialogContext context, IAwaitable<string> input)
  39. {
  40. string title = await input;
  41. if (string.IsNullOrEmpty(title))
  42. {
  43. context.Done<object>(null);
  44. }
  45. else
  46. {
  47. context.Call(new JobsDialog(this.searchClient, this.QueryBuilder), this.Done);
  48. }
  49. }
  50. public async Task Done(IDialogContext context, IAwaitable<IList<SearchHit>> input)
  51. {
  52. var selection = await input;
  53. if (selection != null && selection.Any())
  54. {
  55. string list = string.Join("\n\n", selection.Select(s => $"* {s.Title} ({s.Key})"));
  56. await context.PostAsync($"Done! For future reference, you selected these job listings:\n\n{list}");
  57. }
  58. this.QueryBuilder.Reset();
  59. context.Done<object>(null);
  60. }
  61. }
  62. }
Tip!

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

Comments

Loading...