forked from microsoft/BotBuilder-Samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Cards.cs
209 lines (189 loc) · 8.69 KB
/
Cards.cs
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using System.Collections.Generic;
using System.IO;
using Microsoft.Bot.Schema;
using Newtonsoft.Json;
namespace Microsoft.BotBuilderSamples
{
public static class Cards
{
public static Attachment CreateAdaptiveCardAttachment()
{
// combine path for cross platform support
var paths = new[] { ".", "Resources", "adaptiveCard.json" };
var adaptiveCardJson = File.ReadAllText(Path.Combine(paths));
var adaptiveCardAttachment = new Attachment()
{
ContentType = "application/vnd.microsoft.card.adaptive",
Content = JsonConvert.DeserializeObject(adaptiveCardJson),
};
return adaptiveCardAttachment;
}
public static HeroCard GetHeroCard()
{
var heroCard = new HeroCard
{
Title = "BotFramework Hero Card",
Subtitle = "Microsoft Bot Framework",
Text = "Build and connect intelligent bots to interact with your users naturally wherever they are," +
" from text/sms to Skype, Slack, Office 365 mail and other popular services.",
Images = new List<CardImage> { new CardImage("https://sec.ch9.ms/ch9/7ff5/e07cfef0-aa3b-40bb-9baa-7c9ef8ff7ff5/buildreactionbotframework_960.jpg") },
Buttons = new List<CardAction> { new CardAction(ActionTypes.OpenUrl, "Get Started", value: "https://docs.microsoft.com/bot-framework") },
};
return heroCard;
}
public static ThumbnailCard GetThumbnailCard()
{
var thumbnailCard = new ThumbnailCard
{
Title = "BotFramework Thumbnail Card",
Subtitle = "Microsoft Bot Framework",
Text = "Build and connect intelligent bots to interact with your users naturally wherever they are," +
" from text/sms to Skype, Slack, Office 365 mail and other popular services.",
Images = new List<CardImage> { new CardImage("https://sec.ch9.ms/ch9/7ff5/e07cfef0-aa3b-40bb-9baa-7c9ef8ff7ff5/buildreactionbotframework_960.jpg") },
Buttons = new List<CardAction> { new CardAction(ActionTypes.OpenUrl, "Get Started", value: "https://docs.microsoft.com/bot-framework") },
};
return thumbnailCard;
}
public static ReceiptCard GetReceiptCard()
{
var receiptCard = new ReceiptCard
{
Title = "John Doe",
Facts = new List<Fact> { new Fact("Order Number", "1234"), new Fact("Payment Method", "VISA 5555-****") },
Items = new List<ReceiptItem>
{
new ReceiptItem(
"Data Transfer",
price: "$ 38.45",
quantity: "368",
image: new CardImage(url: "https://github.com/amido/azure-vector-icons/raw/master/renders/traffic-manager.png")),
new ReceiptItem(
"App Service",
price: "$ 45.00",
quantity: "720",
image: new CardImage(url: "https://github.com/amido/azure-vector-icons/raw/master/renders/cloud-service.png")),
},
Tax = "$ 7.50",
Total = "$ 90.95",
Buttons = new List<CardAction>
{
new CardAction(
ActionTypes.OpenUrl,
"More information",
"https://account.windowsazure.com/content/6.10.1.38-.8225.160809-1618/aux-pre/images/offer-icon-freetrial.png",
value: "https://azure.microsoft.com/en-us/pricing/"),
},
};
return receiptCard;
}
public static SigninCard GetSigninCard()
{
var signinCard = new SigninCard
{
Text = "BotFramework Sign-in Card",
Buttons = new List<CardAction> { new CardAction(ActionTypes.Signin, "Sign-in", value: "https://login.microsoftonline.com/") },
};
return signinCard;
}
public static AnimationCard GetAnimationCard()
{
var animationCard = new AnimationCard
{
Title = "Microsoft Bot Framework",
Subtitle = "Animation Card",
Image = new ThumbnailUrl
{
Url = "https://docs.microsoft.com/en-us/bot-framework/media/how-it-works/architecture-resize.png",
},
Media = new List<MediaUrl>
{
new MediaUrl()
{
Url = "http://i.giphy.com/Ki55RUbOV5njy.gif",
},
},
};
return animationCard;
}
public static VideoCard GetVideoCard()
{
var videoCard = new VideoCard
{
Title = "Big Buck Bunny",
Subtitle = "by the Blender Institute",
Text = "Big Buck Bunny (code-named Peach) is a short computer-animated comedy film by the Blender Institute," +
" part of the Blender Foundation. Like the foundation's previous film Elephants Dream," +
" the film was made using Blender, a free software application for animation made by the same foundation." +
" It was released as an open-source film under Creative Commons License Attribution 3.0.",
Image = new ThumbnailUrl
{
Url = "https://upload.wikimedia.org/wikipedia/commons/thumb/c/c5/Big_buck_bunny_poster_big.jpg/220px-Big_buck_bunny_poster_big.jpg",
},
Media = new List<MediaUrl>
{
new MediaUrl()
{
Url = "http://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_320x180.mp4",
},
},
Buttons = new List<CardAction>
{
new CardAction()
{
Title = "Learn More",
Type = ActionTypes.OpenUrl,
Value = "https://peach.blender.org/",
},
},
};
return videoCard;
}
public static AudioCard GetAudioCard()
{
var audioCard = new AudioCard
{
Title = "I am your father",
Subtitle = "Star Wars: Episode V - The Empire Strikes Back",
Text = "The Empire Strikes Back (also known as Star Wars: Episode V – The Empire Strikes Back)" +
" is a 1980 American epic space opera film directed by Irvin Kershner. Leigh Brackett and" +
" Lawrence Kasdan wrote the screenplay, with George Lucas writing the film's story and serving" +
" as executive producer. The second installment in the original Star Wars trilogy, it was produced" +
" by Gary Kurtz for Lucasfilm Ltd. and stars Mark Hamill, Harrison Ford, Carrie Fisher, Billy Dee Williams," +
" Anthony Daniels, David Prowse, Kenny Baker, Peter Mayhew and Frank Oz.",
Image = new ThumbnailUrl
{
Url = "https://upload.wikimedia.org/wikipedia/en/3/3c/SW_-_Empire_Strikes_Back.jpg",
},
Media = new List<MediaUrl>
{
new MediaUrl()
{
Url = "https://wavlist.com/wav/father.wav",
},
},
Buttons = new List<CardAction>
{
new CardAction()
{
Title = "Read More",
Type = ActionTypes.OpenUrl,
Value = "https://en.wikipedia.org/wiki/The_Empire_Strikes_Back",
},
},
};
return audioCard;
}
public static OAuthCard GetOAuthCard()
{
var oauthCard = new OAuthCard
{
Text = "BotFramework OAuth Card",
ConnectionName = "OAuth connection", // Replace with the name of your Azure AD connection.
Buttons = new List<CardAction> { new CardAction(ActionTypes.Signin, "Sign In", value: "https://example.org/signin") },
};
return oauthCard;
}
}
}