diff --git a/FunctionalTests/Skills/DialogToDialog/DialogRootBot/Dialogs/MainDialog.cs b/FunctionalTests/Skills/DialogToDialog/DialogRootBot/Dialogs/MainDialog.cs index 04cdcad493..bd6445b54b 100644 --- a/FunctionalTests/Skills/DialogToDialog/DialogRootBot/Dialogs/MainDialog.cs +++ b/FunctionalTests/Skills/DialogToDialog/DialogRootBot/Dialogs/MainDialog.cs @@ -178,7 +178,7 @@ private async Task CallSkillActionStepAsync(WaterfallStepConte skillDialogArgs.Activity.Properties = stepContext.Context.Activity.Properties; // Comment or uncomment this line if you need to enable or disabled buffered replies. - skillDialogArgs.Activity.DeliveryMode = DeliveryModes.BufferedReplies; + skillDialogArgs.Activity.DeliveryMode = DeliveryModes.ExpectReplies; // Save active skill in state await _activeSkillProperty.SetAsync(stepContext.Context, selectedSkill, cancellationToken); diff --git a/libraries/Microsoft.Bot.Builder.Dialogs/SkillDialog.cs b/libraries/Microsoft.Bot.Builder.Dialogs/SkillDialog.cs index 2503c17345..adff6d2061 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs/SkillDialog.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs/SkillDialog.cs @@ -168,7 +168,7 @@ private async Task SendToSkillAsync(ITurnContext context, Activity act var skillInfo = DialogOptions.Skill; await DialogOptions.ConversationState.SaveChangesAsync(context, true, cancellationToken).ConfigureAwait(false); - var response = await DialogOptions.SkillClient.PostActivityAsync(DialogOptions.BotId, skillInfo.AppId, skillInfo.SkillEndpoint, DialogOptions.SkillHostEndpoint, skillConversationId, activity, cancellationToken).ConfigureAwait(false); + var response = await DialogOptions.SkillClient.PostActivityAsync(DialogOptions.BotId, skillInfo.AppId, skillInfo.SkillEndpoint, DialogOptions.SkillHostEndpoint, skillConversationId, activity, cancellationToken).ConfigureAwait(false); // Inspect the skill response status if (!(response.Status >= 200 && response.Status <= 299)) @@ -177,10 +177,10 @@ private async Task SendToSkillAsync(ITurnContext context, Activity act } Activity eocActivity = null; - if (activity.DeliveryMode == DeliveryModes.BufferedReplies && response.Body.Any()) + if (activity.DeliveryMode == DeliveryModes.ExpectReplies && response.Body.Activities != null && response.Body.Activities.Any()) { // Process replies in the response.Body. - foreach (var fromSkillActivity in response.Body) + foreach (var fromSkillActivity in response.Body.Activities) { if (fromSkillActivity.Type == ActivityTypes.EndOfConversation) { diff --git a/libraries/Microsoft.Bot.Builder/BotFrameworkAdapter.cs b/libraries/Microsoft.Bot.Builder/BotFrameworkAdapter.cs index 0d84bba773..801fd58477 100644 --- a/libraries/Microsoft.Bot.Builder/BotFrameworkAdapter.cs +++ b/libraries/Microsoft.Bot.Builder/BotFrameworkAdapter.cs @@ -456,9 +456,9 @@ public override async Task ProcessActivityAsync(ClaimsIdentity c return (InvokeResponse)activityInvokeResponse.Value; } - else if (context.Activity.DeliveryMode == DeliveryModes.BufferedReplies) + else if (context.Activity.DeliveryMode == DeliveryModes.ExpectReplies) { - return new InvokeResponse { Status = (int)HttpStatusCode.OK, Body = context.BufferedReplies }; + return new InvokeResponse { Status = (int)HttpStatusCode.OK, Body = new ExpectedReplies(context.BufferedReplyActivities) }; } // For all non-invoke scenarios, the HTTP layers above don't have to mess diff --git a/libraries/Microsoft.Bot.Builder/TurnContext.cs b/libraries/Microsoft.Bot.Builder/TurnContext.cs index 1d53b5497b..c1e0baefb3 100644 --- a/libraries/Microsoft.Bot.Builder/TurnContext.cs +++ b/libraries/Microsoft.Bot.Builder/TurnContext.cs @@ -70,10 +70,10 @@ public bool Responded } /// - /// Gets a list of activities to send when `context.Activity.DeliveryMode == 'bufferedReplies'`. + /// Gets a list of activities to send when `context.Activity.DeliveryMode == 'expectReplies'. /// /// A list of activities. - public List BufferedReplies { get; } = new List(); + public List BufferedReplyActivities { get; } = new List(); /// /// Adds a response handler for send activity operations. @@ -267,7 +267,7 @@ Task SendActivitiesThroughCallbackPipeline(int nextCallbackI async Task SendActivitiesThroughAdapter() { - if (Activity.DeliveryMode == DeliveryModes.BufferedReplies) + if (Activity.DeliveryMode == DeliveryModes.ExpectReplies) { var responses = new ResourceResponse[bufferedActivities.Count]; var sentNonTraceActivity = false; @@ -275,7 +275,7 @@ async Task SendActivitiesThroughAdapter() for (var index = 0; index < responses.Length; index++) { var activity = bufferedActivities[index]; - BufferedReplies.Add(activity); + BufferedReplyActivities.Add(activity); responses[index] = new ResourceResponse(); sentNonTraceActivity |= activity.Type != ActivityTypes.Trace; diff --git a/libraries/Microsoft.Bot.Schema/DeliveryModes.cs b/libraries/Microsoft.Bot.Schema/DeliveryModes.cs index 895b57fe1b..f511e4cf38 100644 --- a/libraries/Microsoft.Bot.Schema/DeliveryModes.cs +++ b/libraries/Microsoft.Bot.Schema/DeliveryModes.cs @@ -18,6 +18,6 @@ public static class DeliveryModes { public const string Normal = "normal"; public const string Notification = "notification"; - public const string BufferedReplies = "bufferedReplies"; + public const string ExpectReplies = "expectReplies"; } } diff --git a/libraries/Microsoft.Bot.Schema/ExpectedReplies.cs b/libraries/Microsoft.Bot.Schema/ExpectedReplies.cs new file mode 100644 index 0000000000..0bd93d0ca6 --- /dev/null +++ b/libraries/Microsoft.Bot.Schema/ExpectedReplies.cs @@ -0,0 +1,53 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Bot.Schema +{ + using Newtonsoft.Json; + using System.Collections.Generic; + + /// + /// Replies in response to + /// + public partial class ExpectedReplies + { + /// + /// Initializes a new instance of the ExpectedReplies class. + /// + public ExpectedReplies() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ExpectedReplies class. + /// + /// A collection of Activities that conforms + /// to the ExpectedReplies schema. + public ExpectedReplies(IList activities = default(IList)) + { + Activities = activities; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets a collection of Activities that conforms to the + /// ExpectedReplies schema. + /// + [JsonProperty(PropertyName = "activities")] + public IList Activities { get; set; } + + } +} diff --git a/tests/Microsoft.Bot.Builder.Dialogs.Tests/SkillDialogTests.cs b/tests/Microsoft.Bot.Builder.Dialogs.Tests/SkillDialogTests.cs index 3200cbe8bc..8d848e5cb7 100644 --- a/tests/Microsoft.Bot.Builder.Dialogs.Tests/SkillDialogTests.cs +++ b/tests/Microsoft.Bot.Builder.Dialogs.Tests/SkillDialogTests.cs @@ -160,15 +160,15 @@ private static Mock CreateMockSkillClient(Action x.PostActivityAsync(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) - .Returns(Task.FromResult(new InvokeResponse { Status = returnStatus })) + .Setup(x => x.PostActivityAsync(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) + .Returns(Task.FromResult(new InvokeResponse { Status = returnStatus })) .Callback(captureAction); } else { mockSkillClient - .Setup(x => x.PostActivityAsync(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) - .Returns(Task.FromResult(new InvokeResponse { Status = returnStatus })); + .Setup(x => x.PostActivityAsync(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) + .Returns(Task.FromResult(new InvokeResponse { Status = returnStatus })); } return mockSkillClient; diff --git a/tests/Microsoft.Bot.Builder.Tests/BotFrameworkAdapterTests.cs b/tests/Microsoft.Bot.Builder.Tests/BotFrameworkAdapterTests.cs index 32ce459a09..35288dae9e 100644 --- a/tests/Microsoft.Bot.Builder.Tests/BotFrameworkAdapterTests.cs +++ b/tests/Microsoft.Bot.Builder.Tests/BotFrameworkAdapterTests.cs @@ -358,7 +358,7 @@ public async Task ContinueConversationAsyncWithAudience() } [TestMethod] - public async Task DeliveryModeBufferedReplies() + public async Task DeliveryModeExpectReplies() { var mockCredentialProvider = new Mock(); var mockHttpMessageHandler = new Mock(); @@ -381,14 +381,14 @@ public async Task DeliveryModeBufferedReplies() Type = ActivityTypes.Message, ChannelId = Channels.Emulator, ServiceUrl = "http://tempuri.org/whatever", - DeliveryMode = DeliveryModes.BufferedReplies, + DeliveryMode = DeliveryModes.ExpectReplies, Text = "hello world" }; var invokeResponse = await adapter.ProcessActivityAsync(string.Empty, inboundActivity, callback, CancellationToken.None); Assert.AreEqual((int)HttpStatusCode.OK, invokeResponse.Status); - var activities = (List)invokeResponse.Body; + var activities = ((ExpectedReplies)invokeResponse.Body).Activities; Assert.AreEqual(3, activities.Count); Assert.AreEqual("activity 1", activities[0].Text); Assert.AreEqual("activity 2", activities[1].Text); diff --git a/tests/Skills/Parent/ParentBot.cs b/tests/Skills/Parent/ParentBot.cs index 0035330c7e..80631a45e1 100644 --- a/tests/Skills/Parent/ParentBot.cs +++ b/tests/Skills/Parent/ParentBot.cs @@ -76,8 +76,8 @@ protected override async Task OnMessageActivityAsync(ITurnContext( + cloneActivity.DeliveryMode = DeliveryModes.ExpectReplies; + var response1 = await _client.PostActivityAsync( _fromBotId, _toBotId, new Uri("http://localhost:2303/api/messages"), @@ -86,11 +86,12 @@ protected override async Task OnMessageActivityAsync(ITurnContext( + var response = await _client.PostActivityAsync( _fromBotId, _toBotId, new Uri("http://localhost:2303/api/messages"), @@ -115,7 +116,7 @@ protected override async Task OnMessageActivityAsync(ITurnContext