microsoft/teams.net
Publicmirrored fromhttps://github.com/microsoft/teams.netAvailable
core/samples/MessageExtensionBot/Cards.cs
117lines · modecode
| 1 | // Copyright (c) Microsoft Corporation. |
| 2 | // Licensed under the MIT License. |
| 3 | |
| 4 | namespace MessageExtensionBot; |
| 5 | |
| 6 | public static class Cards |
| 7 | { |
| 8 | public static object[] CreateQueryResultCards(string searchText) |
| 9 | { |
| 10 | return new[] |
| 11 | { |
| 12 | new |
| 13 | { |
| 14 | title = $"Result 1: {searchText}", |
| 15 | text = "Click to see full details", |
| 16 | tap = new |
| 17 | { |
| 18 | type = "invoke", |
| 19 | value = new |
| 20 | { |
| 21 | itemId = "item-1", |
| 22 | title = $"Full details for Result 1: {searchText}", |
| 23 | description = "This is the expanded content" |
| 24 | } |
| 25 | } |
| 26 | }, |
| 27 | new |
| 28 | { |
| 29 | title = $"Result 2: {searchText}", |
| 30 | text = "Click to see full details", |
| 31 | tap = new |
| 32 | { |
| 33 | type = "invoke", |
| 34 | value = new |
| 35 | { |
| 36 | itemId = "item-2", |
| 37 | title = $"Full details for Result 2: {searchText}", |
| 38 | description = "This is more expanded content" |
| 39 | } |
| 40 | } |
| 41 | } |
| 42 | }; |
| 43 | } |
| 44 | |
| 45 | public static object CreateSelectItemCard(string? itemId, string? title, string? description) |
| 46 | { |
| 47 | return new |
| 48 | { |
| 49 | type = "AdaptiveCard", |
| 50 | version = "1.4", |
| 51 | body = new object[] |
| 52 | { |
| 53 | new { type = "TextBlock", text = title, size = "large", weight = "bolder" }, |
| 54 | new { type = "TextBlock", text = description, wrap = true }, |
| 55 | new { type = "FactSet", facts = new[] |
| 56 | { |
| 57 | new { title = "Item ID:", value = itemId } |
| 58 | } |
| 59 | } |
| 60 | } |
| 61 | }; |
| 62 | } |
| 63 | |
| 64 | public static object CreateFetchTaskCard(string? commandId) |
| 65 | { |
| 66 | return new |
| 67 | { |
| 68 | type = "AdaptiveCard", |
| 69 | version = "1.4", |
| 70 | body = new object[] |
| 71 | { |
| 72 | new { type = "TextBlock", text = $"Fetch Task for: {commandId}", size = "large", weight = "bolder" }, |
| 73 | new { type = "Input.Text", id = "title", label = "Title", placeholder = "Enter a title" }, |
| 74 | new { type = "Input.Text", id = "description", label = "Description", placeholder = "Enter a description", isMultiline = true } |
| 75 | }, |
| 76 | actions = new object[] |
| 77 | { |
| 78 | new { type = "Action.Submit", title = "Submit" } |
| 79 | } |
| 80 | }; |
| 81 | } |
| 82 | |
| 83 | public static object CreateEditFormCard(string? previewTitle, string? previewDescription) |
| 84 | { |
| 85 | return new |
| 86 | { |
| 87 | type = "AdaptiveCard", |
| 88 | version = "1.4", |
| 89 | body = new object[] |
| 90 | { |
| 91 | new { type = "TextBlock", text = "Edit Your Card", size = "large", weight = "bolder" }, |
| 92 | new { type = "Input.Text", id = "title", label = "Title", placeholder = "Enter a title", value = previewTitle }, |
| 93 | new { type = "Input.Text", id = "description", label = "Description", placeholder = "Enter a description", isMultiline = true, value = previewDescription } |
| 94 | }, |
| 95 | actions = new object[] { new { type = "Action.Submit", title = "Submit" } } |
| 96 | }; |
| 97 | } |
| 98 | |
| 99 | public static object CreateSubmitActionCard(string? title, string? description) |
| 100 | { |
| 101 | return new |
| 102 | { |
| 103 | type = "AdaptiveCard", |
| 104 | version = "1.4", |
| 105 | body = new object[] |
| 106 | { |
| 107 | new { type = "TextBlock", text = title ?? "Untitled", size = "large", weight = "bolder", color = "accent" }, |
| 108 | new { type = "TextBlock", text = description ?? "No description", wrap = true } |
| 109 | } |
| 110 | }; |
| 111 | } |
| 112 | |
| 113 | public static object CreateLinkUnfurlCard(string? url) |
| 114 | { |
| 115 | return new { title = $"Link Unfurled: {url}" }; |
| 116 | } |
| 117 | } |
| 118 | |