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

CarouselCardsDialog.cs 4.6 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
85
86
87
88
  1. namespace CarouselCardsBot
  2. {
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Threading.Tasks;
  6. using Microsoft.Bot.Builder.Dialogs;
  7. using Microsoft.Bot.Connector;
  8. [Serializable]
  9. public class CarouselCardsDialog : IDialog<object>
  10. {
  11. public async Task StartAsync(IDialogContext context)
  12. {
  13. context.Wait(this.MessageReceivedAsync);
  14. }
  15. public virtual async Task MessageReceivedAsync(IDialogContext context, IAwaitable<IMessageActivity> result)
  16. {
  17. var reply = context.MakeMessage();
  18. reply.AttachmentLayout = AttachmentLayoutTypes.Carousel;
  19. reply.Attachments = GetCardsAttachments();
  20. await context.PostAsync(reply);
  21. context.Wait(this.MessageReceivedAsync);
  22. }
  23. private static IList<Attachment> GetCardsAttachments()
  24. {
  25. return new List<Attachment>()
  26. {
  27. GetHeroCard(
  28. "Azure Storage",
  29. "Offload the heavy lifting of data center management",
  30. "Store and help protect your data. Get durable, highly available data storage across the globe and pay only for what you use.",
  31. new CardImage(url: "https://docs.microsoft.com/en-us/azure/storage/media/storage-introduction/storage-concepts.png"),
  32. new CardAction(ActionTypes.OpenUrl, "Learn more", value: "https://azure.microsoft.com/en-us/services/storage/")),
  33. GetThumbnailCard(
  34. "DocumentDB",
  35. "Blazing fast, planet-scale NoSQL",
  36. "NoSQL service for highly available, globally distributed apps—take full advantage of SQL and JavaScript over document and key-value data without the hassles of on-premises or virtual machine-based cloud database options.",
  37. new CardImage(url: "https://docs.microsoft.com/en-us/azure/documentdb/media/documentdb-introduction/json-database-resources1.png"),
  38. new CardAction(ActionTypes.OpenUrl, "Learn more", value: "https://azure.microsoft.com/en-us/services/documentdb/")),
  39. GetHeroCard(
  40. "Azure Functions",
  41. "Process events with a serverless code architecture",
  42. "An event-based serverless compute experience to accelerate your development. It can scale based on demand and you pay only for the resources you consume.",
  43. new CardImage(url: "https://azurecomcdn.azureedge.net/cvt-5daae9212bb433ad0510fbfbff44121ac7c759adc284d7a43d60dbbf2358a07a/images/page/services/functions/01-develop.png"),
  44. new CardAction(ActionTypes.OpenUrl, "Learn more", value: "https://azure.microsoft.com/en-us/services/functions/")),
  45. GetThumbnailCard(
  46. "Cognitive Services",
  47. "Build powerful intelligence into your applications to enable natural and contextual interactions",
  48. "Enable natural and contextual interaction with tools that augment users' experiences using the power of machine-based intelligence. Tap into an ever-growing collection of powerful artificial intelligence algorithms for vision, speech, language, and knowledge.",
  49. new CardImage(url: "https://azurecomcdn.azureedge.net/cvt-68b530dac63f0ccae8466a2610289af04bdc67ee0bfbc2d5e526b8efd10af05a/images/page/services/cognitive-services/cognitive-services.png"),
  50. new CardAction(ActionTypes.OpenUrl, "Learn more", value: "https://azure.microsoft.com/en-us/services/cognitive-services/")),
  51. };
  52. }
  53. private static Attachment GetHeroCard(string title, string subtitle, string text, CardImage cardImage, CardAction cardAction)
  54. {
  55. var heroCard = new HeroCard
  56. {
  57. Title = title,
  58. Subtitle = subtitle,
  59. Text = text,
  60. Images = new List<CardImage>() { cardImage },
  61. Buttons = new List<CardAction>() { cardAction },
  62. };
  63. return heroCard.ToAttachment();
  64. }
  65. private static Attachment GetThumbnailCard(string title, string subtitle, string text, CardImage cardImage, CardAction cardAction)
  66. {
  67. var heroCard = new ThumbnailCard
  68. {
  69. Title = title,
  70. Subtitle = subtitle,
  71. Text = text,
  72. Images = new List<CardImage>() { cardImage },
  73. Buttons = new List<CardAction>() { cardAction },
  74. };
  75. return heroCard.ToAttachment();
  76. }
  77. }
  78. }
Tip!

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

Comments

Loading...