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
|
- namespace CarouselCardsBot
- {
- using System;
- using System.Collections.Generic;
- using System.Threading.Tasks;
- using Microsoft.Bot.Builder.Dialogs;
- using Microsoft.Bot.Connector;
- [Serializable]
- public class CarouselCardsDialog : IDialog<object>
- {
- public async Task StartAsync(IDialogContext context)
- {
- context.Wait(this.MessageReceivedAsync);
- }
- public virtual async Task MessageReceivedAsync(IDialogContext context, IAwaitable<IMessageActivity> result)
- {
- var reply = context.MakeMessage();
- reply.AttachmentLayout = AttachmentLayoutTypes.Carousel;
- reply.Attachments = GetCardsAttachments();
- await context.PostAsync(reply);
- context.Wait(this.MessageReceivedAsync);
- }
- private static IList<Attachment> GetCardsAttachments()
- {
- return new List<Attachment>()
- {
- GetHeroCard(
- "Azure Storage",
- "Offload the heavy lifting of data center management",
- "Store and help protect your data. Get durable, highly available data storage across the globe and pay only for what you use.",
- new CardImage(url: "https://docs.microsoft.com/en-us/azure/storage/media/storage-introduction/storage-concepts.png"),
- new CardAction(ActionTypes.OpenUrl, "Learn more", value: "https://azure.microsoft.com/en-us/services/storage/")),
- GetThumbnailCard(
- "DocumentDB",
- "Blazing fast, planet-scale NoSQL",
- "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.",
- new CardImage(url: "https://docs.microsoft.com/en-us/azure/documentdb/media/documentdb-introduction/json-database-resources1.png"),
- new CardAction(ActionTypes.OpenUrl, "Learn more", value: "https://azure.microsoft.com/en-us/services/documentdb/")),
- GetHeroCard(
- "Azure Functions",
- "Process events with a serverless code architecture",
- "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.",
- new CardImage(url: "https://azurecomcdn.azureedge.net/cvt-5daae9212bb433ad0510fbfbff44121ac7c759adc284d7a43d60dbbf2358a07a/images/page/services/functions/01-develop.png"),
- new CardAction(ActionTypes.OpenUrl, "Learn more", value: "https://azure.microsoft.com/en-us/services/functions/")),
- GetThumbnailCard(
- "Cognitive Services",
- "Build powerful intelligence into your applications to enable natural and contextual interactions",
- "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.",
- new CardImage(url: "https://azurecomcdn.azureedge.net/cvt-68b530dac63f0ccae8466a2610289af04bdc67ee0bfbc2d5e526b8efd10af05a/images/page/services/cognitive-services/cognitive-services.png"),
- new CardAction(ActionTypes.OpenUrl, "Learn more", value: "https://azure.microsoft.com/en-us/services/cognitive-services/")),
- };
- }
- private static Attachment GetHeroCard(string title, string subtitle, string text, CardImage cardImage, CardAction cardAction)
- {
- var heroCard = new HeroCard
- {
- Title = title,
- Subtitle = subtitle,
- Text = text,
- Images = new List<CardImage>() { cardImage },
- Buttons = new List<CardAction>() { cardAction },
- };
- return heroCard.ToAttachment();
- }
- private static Attachment GetThumbnailCard(string title, string subtitle, string text, CardImage cardImage, CardAction cardAction)
- {
- var heroCard = new ThumbnailCard
- {
- Title = title,
- Subtitle = subtitle,
- Text = text,
- Images = new List<CardImage>() { cardImage },
- Buttons = new List<CardAction>() { cardAction },
- };
- return heroCard.ToAttachment();
- }
- }
- }
|