diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Input/ChoiceInput.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Input/ChoiceInput.cs index 4bee722545..b1bbf548bb 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Input/ChoiceInput.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Input/ChoiceInput.cs @@ -230,8 +230,11 @@ protected override async Task OnRenderPromptAsync(DialogContext dc, I var opts = await GetChoiceOptionsAsync(dc, locale).ConfigureAwait(false); var choiceOptions = opts ?? DefaultChoiceOptions[locale]; var options = dc.State.GetValue(ThisPath.Options); + var conversationType = dc.Context.Activity.Conversation?.ConversationType; + var recipient = dc.Context.Activity.From?.Id; + var toList = string.IsNullOrEmpty(recipient) ? null : new List() { recipient }; - return AppendChoices(prompt.AsMessageActivity(), channelId, options.Choices, Style.GetValue(dc.State), choiceOptions); + return AppendChoices(prompt.AsMessageActivity(), channelId, options.Choices, Style.GetValue(dc.State), choiceOptions, conversationType, toList); } private async Task GetChoiceSetAsync(DialogContext dc) diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Input/ConfirmInput.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Input/ConfirmInput.cs index 1d2530ce04..7051c7b22b 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Input/ConfirmInput.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Input/ConfirmInput.cs @@ -175,7 +175,10 @@ protected override async Task OnRenderPromptAsync(DialogContext dc, I var prompt = await base.OnRenderPromptAsync(dc, state, cancellationToken).ConfigureAwait(false); var (style, _) = Style.TryGetValue(dc.State); - return AppendChoices(prompt.AsMessageActivity(), channelId, confirmChoices, style, choiceOptions); + var conversationType = dc.Context.Activity.Conversation?.ConversationType; + var recipient = dc.Context.Activity.From?.Id; + var toList = string.IsNullOrEmpty(recipient) ? null : new List() { recipient }; + return AppendChoices(prompt.AsMessageActivity(), channelId, confirmChoices, style, choiceOptions, conversationType, toList); } private string DetermineCulture(DialogContext dc) diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Input/InputDialog.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Input/InputDialog.cs index 282ecf8a6c..fc1f1953a1 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Input/InputDialog.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Input/InputDialog.cs @@ -379,6 +379,23 @@ protected override async Task OnPreBubbleEventAsync(DialogContext dc, Dial /// cancellation Token. /// bound activity ready to send to the user. protected virtual IMessageActivity AppendChoices(IMessageActivity prompt, string channelId, IList choices, ListStyle style, ChoiceFactoryOptions options = null, CancellationToken cancellationToken = default(CancellationToken)) + { + return AppendChoices(prompt, channelId, choices, style, options, null, null, cancellationToken); + } + + /// + /// AppendChoices is utility method to build up a message activity given all of the options. + /// + /// prompt. + /// channelId. + /// choices to present. + /// listType. + /// options to control the choice rendering. + /// the type of the conversation. + /// the list of recipients. + /// cancellation Token. + /// bound activity ready to send to the user. + protected virtual IMessageActivity AppendChoices(IMessageActivity prompt, string channelId, IList choices, ListStyle style, ChoiceFactoryOptions options = null, string conversationType = default, IList toList = default, CancellationToken cancellationToken = default(CancellationToken)) { // Get base prompt text (if any) var text = prompt != null && !string.IsNullOrEmpty(prompt.Text) ? prompt.Text : string.Empty; @@ -396,7 +413,7 @@ protected override async Task OnPreBubbleEventAsync(DialogContext dc, Dial break; case ListStyle.SuggestedAction: - msg = ChoiceFactory.SuggestedAction(choices, text); + msg = ChoiceFactory.SuggestedAction(choices, text, null, toList); break; case ListStyle.HeroCard: @@ -409,7 +426,7 @@ protected override async Task OnPreBubbleEventAsync(DialogContext dc, Dial break; default: - msg = ChoiceFactory.ForChannel(channelId, choices, text, null, options); + msg = ChoiceFactory.ForChannel(channelId, choices, text, null, options, conversationType, toList); break; } diff --git a/libraries/Microsoft.Bot.Builder.Dialogs/Choices/Channel.cs b/libraries/Microsoft.Bot.Builder.Dialogs/Choices/Channel.cs index c964ce0aaa..a0eb07eb37 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs/Choices/Channel.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs/Choices/Channel.cs @@ -19,6 +19,18 @@ public class Channel /// (Optional) The number of Suggested Actions to check for the Channel. /// True if the Channel supports the buttonCnt total Suggested Actions, False if the Channel does not support that number of Suggested Actions. public static bool SupportsSuggestedActions(string channelId, int buttonCnt = 100) + { + return SupportsSuggestedActions(channelId, buttonCnt, null); + } + + /// + /// Determine if a number of Suggested Actions are supported by a Channel. + /// + /// The Channel to check the if Suggested Actions are supported in. + /// (Optional) The number of Suggested Actions to check for the Channel. + /// (Optional) The type of the conversation. + /// True if the Channel supports the buttonCnt total Suggested Actions, False if the Channel does not support that number of Suggested Actions. + public static bool SupportsSuggestedActions(string channelId, int buttonCnt = 100, string conversationType = default) { switch (channelId) { @@ -42,6 +54,15 @@ public static bool SupportsSuggestedActions(string channelId, int buttonCnt = 10 case Connector.Channels.Webchat: return buttonCnt <= 100; + // https://learn.microsoft.com/en-us/microsoftteams/platform/bots/how-to/conversations/conversation-messages?tabs=dotnet1%2Cdotnet2%2Cdotnet3%2Cdotnet4%2Cdotnet5%2Cdotnet#send-suggested-actions + case Connector.Channels.Msteams: + if (conversationType == "personal") + { + return buttonCnt <= 3; + } + + return false; + default: return false; } diff --git a/libraries/Microsoft.Bot.Builder.Dialogs/Choices/ChoiceFactory.cs b/libraries/Microsoft.Bot.Builder.Dialogs/Choices/ChoiceFactory.cs index 1a4c51ecd4..17bad6beda 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs/Choices/ChoiceFactory.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs/Choices/ChoiceFactory.cs @@ -30,6 +30,27 @@ public class ChoiceFactory /// If the algorithm decides to use a list, for 3 or fewer choices with short titles it will use an inline /// list; otherwise, a numbered list. public static IMessageActivity ForChannel(string channelId, IList list, string text = null, string speak = null, ChoiceFactoryOptions options = null) + { + return ForChannel(channelId, list, text, speak, options, null, null); + } + + /// + /// Creates a message activity that includes a list of choices formatted based on the capabilities of a given channel. + /// + /// A channel ID. The class contains known channel IDs. + /// The list of choices to include. + /// Optional, the text of the message to send. + /// Optional, the text to be spoken by your bot on a speech-enabled channel. + /// Optional, the formatting options to use when rendering as a list. + /// Optional, the type of the conversation. + /// Optional, the list of recipients. + /// The created message activity. + /// The algorithm prefers to format the supplied list of choices as suggested actions but can decide + /// to use a text based list if suggested actions aren't natively supported by the channel, there are too many + /// choices for the channel to display, or the title of any choice is too long. + /// If the algorithm decides to use a list, for 3 or fewer choices with short titles it will use an inline + /// list; otherwise, a numbered list. + public static IMessageActivity ForChannel(string channelId, IList list, string text = null, string speak = null, ChoiceFactoryOptions options = null, string conversationType = default, IList toList = default) { channelId ??= string.Empty; list ??= new List(); @@ -46,7 +67,7 @@ public static IMessageActivity ForChannel(string channelId, IList list, } // Determine list style - var supportsSuggestedActions = Channel.SupportsSuggestedActions(channelId, list.Count); + var supportsSuggestedActions = Channel.SupportsSuggestedActions(channelId, list.Count, conversationType); var supportsCardActions = Channel.SupportsCardActions(channelId, list.Count); var maxActionTitleLength = Channel.MaxActionTitleLength(channelId); var hasMessageFeed = Channel.HasMessageFeed(channelId); @@ -63,7 +84,7 @@ public static IMessageActivity ForChannel(string channelId, IList list, { // We always prefer showing choices using suggested actions. If the titles are too long, however, // we'll have to show them as a text list. - return SuggestedAction(list, text, speak); + return SuggestedAction(list, text, speak, toList); } if (!longTitles && list.Count <= 3) @@ -198,7 +219,20 @@ public static Activity List(IList choices, string text = null, string sp /// An activity with choices as suggested actions. public static IMessageActivity SuggestedAction(IList choices, string text = null, string speak = null) { - return SuggestedAction(ToChoices(choices), text, speak); + return SuggestedAction(ToChoices(choices), text, speak, null); + } + + /// + /// Creates a message activity containing a list of choices that have been added as suggested actions. + /// + /// List of strings representing the choices to add. + /// Optional, text of the message. + /// Optional, SSML text to be spoken by the bot on a speech-enabled channel. + /// Optional, the list of recipients. + /// An activity with choices as suggested actions. + public static IMessageActivity SuggestedAction(IList choices, string text = null, string speak = null, IList toList = default) + { + return SuggestedAction(ToChoices(choices), text, speak, toList); } /// @@ -211,7 +245,21 @@ public static IMessageActivity SuggestedAction(IList choices, string tex public static IMessageActivity SuggestedAction(IList choices, string text = null, string speak = null) { // Return activity with choices as suggested actions - return MessageFactory.SuggestedActions(ExtractActions(choices), text, speak, InputHints.ExpectingInput); + return SuggestedAction(choices, text, speak, null); + } + + /// + /// Creates a message activity containing a list of choices that have been added as suggested actions. + /// + /// The list of choices to add. + /// Optional, text of the message. + /// Optional, SSML text to be spoken by the bot on a speech-enabled channel. + /// Optional, the list of recipients. + /// An activity with choices as suggested actions. + public static IMessageActivity SuggestedAction(IList choices, string text = null, string speak = null, IList toList = default) + { + // Return activity with choices as suggested actions + return MessageFactory.SuggestedActions(ExtractActions(choices), text, speak, InputHints.ExpectingInput, toList); } /// diff --git a/libraries/Microsoft.Bot.Builder.Dialogs/Prompts/ChoicePrompt.cs b/libraries/Microsoft.Bot.Builder.Dialogs/Prompts/ChoicePrompt.cs index 72b11749dd..5779f769dd 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs/Prompts/ChoicePrompt.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs/Prompts/ChoicePrompt.cs @@ -138,13 +138,16 @@ protected override async Task OnPromptAsync( var channelId = turnContext.Activity.ChannelId; var choiceOptions = ChoiceOptions ?? _choiceDefaults[culture]; var choiceStyle = options.Style ?? Style; + var conversationType = turnContext.Activity.Conversation?.ConversationType; + var recipient = turnContext.Activity.From?.Id; + var toList = string.IsNullOrEmpty(recipient) ? null : new List() { recipient }; if (isRetry && options.RetryPrompt != null) { - prompt = AppendChoices(options.RetryPrompt, channelId, choices, choiceStyle, choiceOptions); + prompt = AppendChoices(options.RetryPrompt, channelId, choices, choiceStyle, choiceOptions, conversationType, toList); } else { - prompt = AppendChoices(options.Prompt, channelId, choices, choiceStyle, choiceOptions); + prompt = AppendChoices(options.Prompt, channelId, choices, choiceStyle, choiceOptions, conversationType, toList); } // Send prompt diff --git a/libraries/Microsoft.Bot.Builder.Dialogs/Prompts/ConfirmPrompt.cs b/libraries/Microsoft.Bot.Builder.Dialogs/Prompts/ConfirmPrompt.cs index e50b102e3b..c8ddb3a92f 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs/Prompts/ConfirmPrompt.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs/Prompts/ConfirmPrompt.cs @@ -143,13 +143,16 @@ protected override async Task OnPromptAsync( var confirmChoices = ConfirmChoices ?? Tuple.Create(defaults.Item1, defaults.Item2); var choices = new List { confirmChoices.Item1, confirmChoices.Item2 }; var style = options.Style ?? Style; + var conversationType = turnContext.Activity.Conversation?.ConversationType; + var recipient = turnContext.Activity.From?.Id; + var toList = string.IsNullOrEmpty(recipient) ? null : new List() { recipient }; if (isRetry && options.RetryPrompt != null) { - prompt = AppendChoices(options.RetryPrompt, channelId, choices, style, choiceOptions); + prompt = AppendChoices(options.RetryPrompt, channelId, choices, style, choiceOptions, conversationType, toList); } else { - prompt = AppendChoices(options.Prompt, channelId, choices, style, choiceOptions); + prompt = AppendChoices(options.Prompt, channelId, choices, style, choiceOptions, conversationType, toList); } // Send prompt diff --git a/libraries/Microsoft.Bot.Builder.Dialogs/Prompts/Prompt.cs b/libraries/Microsoft.Bot.Builder.Dialogs/Prompts/Prompt.cs index 334152fc6c..cfe6ae7153 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs/Prompts/Prompt.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs/Prompts/Prompt.cs @@ -276,6 +276,25 @@ protected override async Task OnPreBubbleEventAsync(DialogContext dc, Dial /// A representing the asynchronous operation. /// If the task is successful, the result contains the updated activity. protected virtual IMessageActivity AppendChoices(IMessageActivity prompt, string channelId, IList choices, ListStyle style, ChoiceFactoryOptions options = null, CancellationToken cancellationToken = default) + { + return AppendChoices(prompt, channelId, choices, style, options, null, null, cancellationToken); + } + + /// + /// When overridden in a derived class, appends choices to the activity when the user is prompted for input. + /// + /// The activity to append the choices to. + /// The ID of the user's channel. + /// The choices to append. + /// Indicates how the choices should be presented to the user. + /// The formatting options to use when presenting the choices. + /// The type of the conversation. + /// The list of recipients. + /// A cancellation token that can be used by other objects + /// or threads to receive notice of cancellation. + /// A representing the asynchronous operation. + /// If the task is successful, the result contains the updated activity. + protected virtual IMessageActivity AppendChoices(IMessageActivity prompt, string channelId, IList choices, ListStyle style, ChoiceFactoryOptions options = null, string conversationType = default, IList toList = default, CancellationToken cancellationToken = default) { // Get base prompt text (if any) var text = prompt != null && !string.IsNullOrEmpty(prompt.Text) ? prompt.Text : string.Empty; @@ -293,7 +312,7 @@ protected virtual IMessageActivity AppendChoices(IMessageActivity prompt, string break; case ListStyle.SuggestedAction: - msg = ChoiceFactory.SuggestedAction(choices, text); + msg = ChoiceFactory.SuggestedAction(choices, text, null, toList); break; case ListStyle.HeroCard: @@ -306,7 +325,7 @@ protected virtual IMessageActivity AppendChoices(IMessageActivity prompt, string break; default: - msg = ChoiceFactory.ForChannel(channelId, choices, text, null, options); + msg = ChoiceFactory.ForChannel(channelId, choices, text, null, options, conversationType, toList); break; } diff --git a/libraries/Microsoft.Bot.Builder/MessageFactory.cs b/libraries/Microsoft.Bot.Builder/MessageFactory.cs index 3ed946aa64..1b784376ac 100644 --- a/libraries/Microsoft.Bot.Builder/MessageFactory.cs +++ b/libraries/Microsoft.Bot.Builder/MessageFactory.cs @@ -94,6 +94,45 @@ public static Activity Text(string text, string ssml = null, string inputHint = /// /// public static IMessageActivity SuggestedActions(IEnumerable actions, string text = null, string ssml = null, string inputHint = null) + { + return SuggestedActions(actions, text, ssml, inputHint, null); + } + + /// + /// Returns a message that includes a set of suggested actions and optional text. + /// + /// + /// + /// // Create the activity and add suggested actions. + /// var activity = MessageFactory.SuggestedActions( + /// new string[] { "red", "green", "blue" }, + /// text: "Choose a color"); + /// + /// // Send the activity as a reply to the user. + /// await context.SendActivity(activity); + /// + /// + /// + /// The text of the actions to create. + /// + /// The text of the message to send. + /// Optional, text to be spoken by your bot on a speech-enabled + /// channel. + /// Optional, indicates whether your bot is accepting, + /// expecting, or ignoring user input after the message is delivered to the client. + /// One of: "acceptingInput", "ignoringInput", or "expectingInput". + /// Default is "acceptingInput". + /// Optional, the list of recipients. + /// A message activity containing the suggested actions. + /// + /// is null. + /// This method creates a suggested action for each string in . + /// The created action uses the text for the and + /// and sets the to + /// . + /// + /// + public static IMessageActivity SuggestedActions(IEnumerable actions, string text = null, string ssml = null, string inputHint = null, IList toList = default) { actions = actions ?? throw new ArgumentNullException(nameof(actions)); @@ -110,7 +149,7 @@ public static IMessageActivity SuggestedActions(IEnumerable actions, str cardActions.Add(ca); } - return SuggestedActions(cardActions, text, ssml, inputHint); + return SuggestedActions(cardActions, text, ssml, inputHint, toList); } /// @@ -144,15 +183,51 @@ public static IMessageActivity SuggestedActions(IEnumerable actions, str /// A message activity that contains the suggested actions. /// /// is null. - /// public static IMessageActivity SuggestedActions(IEnumerable cardActions, string text = null, string ssml = null, string inputHint = null) + { + return SuggestedActions(cardActions, text, ssml, inputHint, null); + } + + /// + /// Returns a message that includes a set of suggested actions and optional text. + /// + /// + /// + /// // Create the activity and add suggested actions. + /// var activity = MessageFactory.SuggestedActions( + /// new CardAction[] + /// { + /// new CardAction(title: "red", type: ActionTypes.ImBack, value: "red"), + /// new CardAction( title: "green", type: ActionTypes.ImBack, value: "green"), + /// new CardAction(title: "blue", type: ActionTypes.ImBack, value: "blue") + /// }, text: "Choose a color"); + /// + /// // Send the activity as a reply to the user. + /// await context.SendActivity(activity); + /// + /// + /// + /// The card actions to include. + /// + /// Optional, the text of the message to send. + /// Optional, text to be spoken by your bot on a speech-enabled + /// channel. + /// Optional, indicates whether your bot is accepting, + /// expecting, or ignoring user input after the message is delivered to the client. + /// One of: "acceptingInput", "ignoringInput", or "expectingInput". + /// Default is "acceptingInput". + /// Optional, the list of recipients. + /// A message activity that contains the suggested actions. + /// + /// is null. + public static IMessageActivity SuggestedActions(IEnumerable cardActions, string text = null, string ssml = null, string inputHint = null, IList toList = default) { cardActions = cardActions ?? throw new ArgumentNullException(nameof(cardActions)); var ma = Activity.CreateMessageActivity(); SetTextAndSpeak(ma, text, ssml, inputHint); - ma.SuggestedActions = new SuggestedActions { Actions = cardActions.ToList() }; + ma.SuggestedActions = new SuggestedActions { Actions = cardActions.ToList(), To = toList }; return ma; } diff --git a/tests/Microsoft.Bot.Builder.Dialogs.Tests/ChoiceFactoryTests.cs b/tests/Microsoft.Bot.Builder.Dialogs.Tests/ChoiceFactoryTests.cs index 49c72aa969..064c1debfc 100644 --- a/tests/Microsoft.Bot.Builder.Dialogs.Tests/ChoiceFactoryTests.cs +++ b/tests/Microsoft.Bot.Builder.Dialogs.Tests/ChoiceFactoryTests.cs @@ -47,7 +47,7 @@ public void ShouldRenderUnincludedNumbersChoicesAsAList() [Fact] public void ShouldRenderChoicesAsSuggestedActions() { - var activity = ChoiceFactory.SuggestedAction(colorChoices, "select from:"); + var activity = ChoiceFactory.SuggestedAction(colorChoices, "select from:", null, null); Assert.Equal("select from:", activity.Text); Assert.NotNull(activity.SuggestedActions); Assert.Equal(3, activity.SuggestedActions.Actions.Count); @@ -86,7 +86,7 @@ public void ShouldRenderChoicesAsHeroCard() [Fact] public void ShouldAutomaticallyChooseRenderStyleBasedOnChannelType() { - var activity = ChoiceFactory.ForChannel(Channels.Emulator, colorChoices, "select from:"); + var activity = ChoiceFactory.ForChannel(Channels.Emulator, colorChoices, "select from:", null, null); Assert.Equal("select from:", activity.Text); Assert.NotNull(activity.SuggestedActions); Assert.Equal(3, activity.SuggestedActions.Actions.Count); @@ -104,7 +104,7 @@ public void ShouldAutomaticallyChooseRenderStyleBasedOnChannelType() [Fact] public void ShouldChooseCorrectStylesForCortana() { - var activity = ChoiceFactory.ForChannel(Channels.Cortana, colorChoices, "select from:"); + var activity = ChoiceFactory.ForChannel(Channels.Cortana, colorChoices, "select from:", null, null); Assert.NotNull(activity.Attachments); @@ -123,9 +123,30 @@ public void ShouldChooseCorrectStylesForCortana() } [Fact] - public void ShouldChooseCorrectStylesForTeams() + public void ShouldChooseCorrectStylesForTeamsPersonalChat() { - var activity = ChoiceFactory.ForChannel(Channels.Msteams, colorChoices, "select from:"); + var recipientsList = new List() { "UserId" }; + var activity = ChoiceFactory.ForChannel(Channels.Msteams, colorChoices, "select from:", conversationType: "personal", toList: recipientsList); + + Assert.Equal("select from:", activity.Text); + Assert.NotNull(activity.SuggestedActions); + Assert.Equal(3, activity.SuggestedActions.Actions.Count); + Assert.Equal(ActionTypes.ImBack, activity.SuggestedActions.Actions[0].Type); + Assert.Equal("red", activity.SuggestedActions.Actions[0].Value); + Assert.Equal("red", activity.SuggestedActions.Actions[0].Title); + Assert.Equal(ActionTypes.ImBack, activity.SuggestedActions.Actions[1].Type); + Assert.Equal("green", activity.SuggestedActions.Actions[1].Value); + Assert.Equal("green", activity.SuggestedActions.Actions[1].Title); + Assert.Equal(ActionTypes.ImBack, activity.SuggestedActions.Actions[2].Type); + Assert.Equal("blue", activity.SuggestedActions.Actions[2].Value); + Assert.Equal("blue", activity.SuggestedActions.Actions[2].Title); + Assert.Equal("UserId", activity.SuggestedActions.To[0]); + } + + [Fact] + public void ShouldChooseCorrectStylesForTeamsGroupChat() + { + var activity = ChoiceFactory.ForChannel(Channels.Msteams, colorChoices, "select from:", conversationType: "groupChat"); Assert.NotNull(activity.Attachments); @@ -146,7 +167,7 @@ public void ShouldChooseCorrectStylesForTeams() [Fact] public void ShouldIncludeChoiceActionsInSuggestedActions() { - var activity = ChoiceFactory.SuggestedAction(choicesWithActions, "select from:"); + var activity = ChoiceFactory.SuggestedAction(choicesWithActions, "select from:", null, null); Assert.Equal("select from:", activity.Text); Assert.NotNull(activity.SuggestedActions); Assert.Equal(3, activity.SuggestedActions.Actions.Count); diff --git a/tests/Microsoft.Bot.Builder.Dialogs.Tests/ChoicesChannelTests.cs b/tests/Microsoft.Bot.Builder.Dialogs.Tests/ChoicesChannelTests.cs index 27220592e2..cde5eab6a7 100644 --- a/tests/Microsoft.Bot.Builder.Dialogs.Tests/ChoicesChannelTests.cs +++ b/tests/Microsoft.Bot.Builder.Dialogs.Tests/ChoicesChannelTests.cs @@ -75,6 +75,27 @@ public void ShouldReturnTrueForSupportsSuggestedActionsWithDirectLineSpeechAnd10 Assert.True(supports); } + [Fact] + public void ShouldReturnTrueForSupportsSuggestedActionsWithTeamsAndPersonalAnd3() + { + var supports = Channel.SupportsSuggestedActions(Channels.Msteams, 3, "personal"); + Assert.True(supports); + } + + [Fact] + public void ShouldReturnFalseForSupportsSuggestedActionsWithTeamsAndPersonalAnd4() + { + var supports = Channel.SupportsSuggestedActions(Channels.Msteams, 4, "personal"); + Assert.False(supports); + } + + [Fact] + public void ShouldReturnFalseForSupportsSuggestedActionsWithTeamsAndGroupChat() + { + var supports = Channel.SupportsSuggestedActions(Channels.Msteams, 3, "groupChat"); + Assert.False(supports); + } + [Fact] public void ShouldReturnTrueForSupportsCardActionsWithDirectLineSpeechAnd99() { diff --git a/tests/Microsoft.Bot.Builder.Tests/MessageFactoryTests.cs b/tests/Microsoft.Bot.Builder.Tests/MessageFactoryTests.cs index 2b953b93ac..49cd7f56b7 100644 --- a/tests/Microsoft.Bot.Builder.Tests/MessageFactoryTests.cs +++ b/tests/Microsoft.Bot.Builder.Tests/MessageFactoryTests.cs @@ -223,13 +223,13 @@ public void AttachmentSingle() [Fact] public void SuggestedActionsCardActionCollectionNull() { - Assert.Throws(() => MessageFactory.SuggestedActions((IEnumerable)null)); + Assert.Throws(() => MessageFactory.SuggestedActions((IEnumerable)null, null, null, null)); } [Fact] public void SuggestedActionsStringCollectionNull() { - Assert.Throws(() => MessageFactory.SuggestedActions((IEnumerable)null)); + Assert.Throws(() => MessageFactory.SuggestedActions((IEnumerable)null, null, null, null)); } [Fact] @@ -432,7 +432,9 @@ async Task ReplyWithImBack(ITurnContext ctx, CancellationToken cancellationToken { new CardAction(type: "imBack", text: "red", title: "redTitle"), }, - inputText); + inputText, + null, + null); await ctx.SendActivityAsync((Activity)activity); }