microsoft/teams.net

Public

mirrored from https://github.com/microsoft/teams.netAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
next/oauth-card-null-ref-bug

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

core/src/Microsoft.Teams.Bot.Apps/Schema/SuggestedAction.cs

131lines · modecode

1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
4using System.Text.Json.Serialization;
5
6namespace Microsoft.Teams.Bot.Apps.Schema;
7
8/// <summary>
9/// Represents a clickable action
10/// </summary>
11public class SuggestedAction
12{
13 /// <summary>
14 /// Default constructor for JSON deserialization.
15 /// </summary>
16 public SuggestedAction()
17 {
18 }
19
20 /// <summary>
21 /// Initializes a new instance of the <see cref="SuggestedAction"/> class with the specified type and title.
22 /// </summary>
23 /// <param name="type">The type of action. See <see cref="ActionType"/> for common values.</param>
24 /// <param name="title">The text description displayed on the button.</param>
25 public SuggestedAction(string type, string title)
26 {
27 Type = type;
28 Title = title;
29 }
30
31 /// <summary>
32 /// Gets or sets the type of action implemented by this button.
33 /// See <see cref="ActionType"/> for common values.
34 /// </summary>
35 [JsonPropertyName("type")]
36 public string? Type { get; set; }
37
38 /// <summary>
39 /// Gets or sets the text description which appears on the button.
40 /// </summary>
41 [JsonPropertyName("title")]
42 public string? Title { get; set; }
43
44 /// <summary>
45 /// Gets or sets the image URL which will appear on the button, next to the text label.
46 /// </summary>
47 [JsonPropertyName("image")]
48 public string? Image { get; set; }
49
50 /// <summary>
51 /// Gets or sets the text for this action.
52 /// </summary>
53 [JsonPropertyName("text")]
54 public string? Text { get; set; }
55
56 /// <summary>
57 /// Gets or sets the text to display in the chat feed if the button is clicked.
58 /// </summary>
59 [JsonPropertyName("displayText")]
60 public string? DisplayText { get; set; }
61
62 /// <summary>
63 /// Gets or sets the supplementary parameter for the action.
64 /// The content of this property depends on the action type.
65 /// </summary>
66 [JsonPropertyName("value")]
67 public object? Value { get; set; }
68
69 /// <summary>
70 /// Gets or sets the channel-specific data associated with this action.
71 /// </summary>
72 [JsonPropertyName("channelData")]
73 public object? ChannelData { get; set; }
74
75 /// <summary>
76 /// Gets or sets the alternate image text to be used in place of the image.
77 /// </summary>
78 [JsonPropertyName("imageAltText")]
79 public string? ImageAltText { get; set; }
80}
81
82/// <summary>
83/// String constants for card action types.
84/// </summary>
85public static class ActionType
86{
87 /// <summary>
88 /// Opens the specified URL in the browser.
89 /// </summary>
90 public const string OpenUrl = "openUrl";
91
92 /// <summary>
93 /// Sends a message back to the bot as if the user typed it (visible to all conversation members).
94 /// </summary>
95 public const string IMBack = "imBack";
96
97 /// <summary>
98 /// Sends a message back to the bot privately (not visible to other conversation members).
99 /// </summary>
100 public const string PostBack = "postBack";
101
102 /// <summary>
103 /// Plays the specified audio content.
104 /// </summary>
105 public const string PlayAudio = "playAudio";
106
107 /// <summary>
108 /// Plays the specified video content.
109 /// </summary>
110 public const string PlayVideo = "playVideo";
111
112 /// <summary>
113 /// Displays the specified image.
114 /// </summary>
115 public const string ShowImage = "showImage";
116
117 /// <summary>
118 /// Downloads the specified file.
119 /// </summary>
120 public const string DownloadFile = "downloadFile";
121
122 /// <summary>
123 /// Initiates a sign-in flow.
124 /// </summary>
125 public const string SignIn = "signin";
126
127 /// <summary>
128 /// Initiates a phone call.
129 /// </summary>
130 public const string Call = "call";
131}
132