microsoft/teams.net

Public

mirrored fromhttps://github.com/microsoft/teams.netAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
samples/migration-bot

Branches

Tags

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

Clone

HTTPS

Download ZIP

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

68lines · 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 suggested actions that can be shown to the user as quick reply buttons.
10/// </summary>
11public class SuggestedActions
12{
13 /// <summary>
14 /// Gets or sets the IDs of the recipients that the actions should be shown to.
15 /// These IDs are relative to the channelId and a subset of all recipients of the activity.
16 /// </summary>
17 [JsonPropertyName("to")]
18 public IList<string> To { get; set; } = [];
19
20 /// <summary>
21 /// Gets or sets the actions that can be shown to the user.
22 /// </summary>
23 [JsonPropertyName("actions")]
24 public IList<SuggestedAction> Actions { get; set; } = [];
25
26 /// <summary>
27 /// Adds recipients to the suggested actions.
28 /// </summary>
29 /// <param name="recipients">The recipient IDs to add.</param>
30 /// <returns>This instance for chaining.</returns>
31 public SuggestedActions AddRecipients(params string[] recipients)
32 {
33 ArgumentNullException.ThrowIfNull(recipients);
34 foreach (var to in recipients)
35 {
36 To.Add(to);
37 }
38
39 return this;
40 }
41
42 /// <summary>
43 /// Adds a single action to the suggested actions.
44 /// </summary>
45 /// <param name="action">The action to add.</param>
46 /// <returns>This instance for chaining.</returns>
47 public SuggestedActions AddAction(SuggestedAction action)
48 {
49 Actions.Add(action);
50 return this;
51 }
52
53 /// <summary>
54 /// Adds multiple actions to the suggested actions.
55 /// </summary>
56 /// <param name="actions">The actions to add.</param>
57 /// <returns>This instance for chaining.</returns>
58 public SuggestedActions AddActions(params SuggestedAction[] actions)
59 {
60 ArgumentNullException.ThrowIfNull(actions);
61 foreach (var action in actions)
62 {
63 Actions.Add(action);
64 }
65
66 return this;
67 }
68}
69