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

ChannelDataDialog.cs 2.9 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
72
73
74
75
76
77
78
79
80
81
82
83
84
  1. namespace ChannelDataBot
  2. {
  3. using System;
  4. using System.Threading.Tasks;
  5. using Microsoft.Bot.Builder.Dialogs;
  6. using Microsoft.Bot.Connector;
  7. using Models;
  8. [Serializable]
  9. public class ChannelDataDialog : IDialog<object>
  10. {
  11. public async Task StartAsync(IDialogContext context)
  12. {
  13. context.Wait(this.MessageReceivedAsync);
  14. }
  15. public async virtual Task MessageReceivedAsync(IDialogContext context, IAwaitable<IMessageActivity> result)
  16. {
  17. var message = await result;
  18. await context.PostAsync("Looking into your upcoming flights to see if you can check-in on any of those...");
  19. var flightAttachment = GetFlightAttachment();
  20. var reply = context.MakeMessage();
  21. if (message.ChannelId != "facebook")
  22. {
  23. reply.Text = flightAttachment.ToString();
  24. }
  25. else
  26. {
  27. reply.ChannelData = new FacebookChannelData()
  28. {
  29. Attachment = flightAttachment
  30. };
  31. }
  32. await context.PostAsync(reply);
  33. context.Wait(this.MessageReceivedAsync);
  34. }
  35. private static FacebookAttachment GetFlightAttachment()
  36. {
  37. return new FacebookAttachment()
  38. {
  39. Payload = new AirlineCheckIn()
  40. {
  41. IntroMessage = "Check-in is available now",
  42. Locale = "en_US",
  43. PnrNumber = "ABCDEF",
  44. CheckInUrl = "http://www.airline.com/check_in",
  45. FlightInfo = new[]
  46. {
  47. new FlightInfo()
  48. {
  49. FlightNumber = "F001",
  50. DepartureAirport = new Airport()
  51. {
  52. AirportCode = "SFO",
  53. City = "San Francisco",
  54. Terminal = "T4",
  55. Gate = "G8"
  56. },
  57. ArrivalAirport = new Airport()
  58. {
  59. AirportCode = "EZE",
  60. City = "Buenos Aires",
  61. Terminal = "C",
  62. Gate = "A2"
  63. },
  64. FlightSchedule = new FlightSchedule()
  65. {
  66. BoardingTime = DateTime.Now.AddDays(1).ToString("yyyy-MM-ddTH:mm"),
  67. DepartureTime = DateTime.Now.AddDays(1).AddHours(1.5).ToString("yyy-MM-ddTH:mm"),
  68. ArrivalTime = DateTime.Now.AddDays(2).ToString("yyyy-MM-ddTH:mm")
  69. }
  70. }
  71. }
  72. }
  73. };
  74. }
  75. }
  76. }
Tip!

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

Comments

Loading...