diff --git a/lib/csharp/microsoft.bot.builder.skills/Microsoft.Bot.Builder.Skills.Tests/SkillDialogTest.cs b/lib/csharp/microsoft.bot.builder.skills/Microsoft.Bot.Builder.Skills.Tests/SkillDialogTest.cs index c9c300a6dd..693231e4bc 100644 --- a/lib/csharp/microsoft.bot.builder.skills/Microsoft.Bot.Builder.Skills.Tests/SkillDialogTest.cs +++ b/lib/csharp/microsoft.bot.builder.skills/Microsoft.Bot.Builder.Skills.Tests/SkillDialogTest.cs @@ -14,10 +14,11 @@ namespace Microsoft.Bot.Builder.Skills.Tests internal class SkillDialogTest : SkillDialog { private MockHttpMessageHandler _mockHttpMessageHandler; + public SkillDialogTest(SkillManifest skillManifest, ResponseManager responseManager, MicrosoftAppCredentialsEx microsoftAppCredentialsEx, IBotTelemetryClient telemetryClient, MockHttpMessageHandler mockHttpMessageHandler, UserState userState) : base(skillManifest, responseManager, microsoftAppCredentialsEx, telemetryClient, userState) { _mockHttpMessageHandler = mockHttpMessageHandler; - _httpClient = mockHttpMessageHandler.ToHttpClient(); + HttpClient = mockHttpMessageHandler.ToHttpClient(); } } } diff --git a/lib/csharp/microsoft.bot.builder.skills/Microsoft.Bot.Builder.Skills.Tests/SkillDialogTestBase.cs b/lib/csharp/microsoft.bot.builder.skills/Microsoft.Bot.Builder.Skills.Tests/SkillDialogTestBase.cs index 2e4fbae785..15c38013ea 100644 --- a/lib/csharp/microsoft.bot.builder.skills/Microsoft.Bot.Builder.Skills.Tests/SkillDialogTestBase.cs +++ b/lib/csharp/microsoft.bot.builder.skills/Microsoft.Bot.Builder.Skills.Tests/SkillDialogTestBase.cs @@ -16,7 +16,9 @@ namespace Microsoft.Bot.Builder.Skills.Tests public class SkillDialogTestBase : BotTestBase { public IServiceCollection Services { get; set; } + public DialogSet Dialogs { get; set; } + public UserState UserState { get; set; } public IStatePropertyAccessor SkillContextAccessor { get; set; } diff --git a/lib/csharp/microsoft.bot.builder.skills/Microsoft.Bot.Builder.Skills.Tests/SkillMiddlewareTests.cs b/lib/csharp/microsoft.bot.builder.skills/Microsoft.Bot.Builder.Skills.Tests/SkillMiddlewareTests.cs new file mode 100644 index 0000000000..4bfec83232 --- /dev/null +++ b/lib/csharp/microsoft.bot.builder.skills/Microsoft.Bot.Builder.Skills.Tests/SkillMiddlewareTests.cs @@ -0,0 +1,170 @@ +using Microsoft.Bot.Builder.Adapters; +using Microsoft.Bot.Builder.Solutions.Testing; +using Microsoft.Bot.Schema; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; + +namespace Microsoft.Bot.Builder.Skills.Tests +{ + [TestClass] + public class SkillMiddlewareTests + { + private ServiceCollection _serviceCollection; + private UserState _userState; + private IStatePropertyAccessor _skillContextAccessor; + + [TestInitialize] + public void AddSkillManifest() + { + // Initialize service collection + _serviceCollection = new ServiceCollection(); + + var conversationState = new ConversationState(new MemoryStorage()); + _serviceCollection.AddSingleton(conversationState); + _userState = new UserState(new MemoryStorage()); + _skillContextAccessor = _userState.CreateProperty(nameof(SkillContext)); + _serviceCollection.AddSingleton(_userState); + + _serviceCollection.AddSingleton(sp => + { + return new BotStateSet(_userState, conversationState); + }); + + _serviceCollection.AddSingleton(); + + } + + [TestMethod] + public async Task SkillMiddlewarePopulatesSkillContext() + { + string jsonSkillBeginActivity = await File.ReadAllTextAsync(@".\TestData\skillBeginEvent.json"); + var skillBeginEvent = JsonConvert.DeserializeObject(jsonSkillBeginActivity); + + var skillContextData = new SkillContext(); + skillContextData.Add("PARAM1", "TEST1"); + skillContextData.Add("PARAM2", "TEST2"); + + // Ensure we have a copy + skillBeginEvent.Value = new SkillContext(skillContextData); + + TestAdapter adapter = new TestAdapter() + .Use(new SkillMiddleware(_userState)); + + var testFlow = new TestFlow(adapter, async (context, cancellationToken) => + { + // Validate that SkillContext has been populated by the SKillMiddleware correctly + await ValidateSkillContextData(context, skillContextData); + }); + + await testFlow.Test(new Activity[] { skillBeginEvent }).StartTestAsync(); + } + + [TestMethod] + public async Task SkillMiddlewarePopulatesSkillContextDifferentDatatypes() + { + string jsonSkillBeginActivity = await File.ReadAllTextAsync(@".\TestData\skillBeginEvent.json"); + var skillBeginEvent = JsonConvert.DeserializeObject(jsonSkillBeginActivity); + + var skillContextData = new SkillContext(); + skillContextData.Add("PARAM1", DateTime.Now); + skillContextData.Add("PARAM2", 3); + skillContextData.Add("PARAM3", null); + + // Ensure we have a copy + skillBeginEvent.Value = new SkillContext(skillContextData); + + TestAdapter adapter = new TestAdapter() + .Use(new SkillMiddleware(_userState)); + + var testFlow = new TestFlow(adapter, async (context, cancellationToken) => + { + // Validate that SkillContext has been populated by the SKillMiddleware correctly + await ValidateSkillContextData(context, skillContextData); + }); + + await testFlow.Test(new Activity[] { skillBeginEvent }).StartTestAsync(); + } + + [TestMethod] + public async Task SkillMiddlewareEmptySkillContext() + { + string jsonSkillBeginActivity = await File.ReadAllTextAsync(@".\TestData\skillBeginEvent.json"); + var skillBeginEvent = JsonConvert.DeserializeObject(jsonSkillBeginActivity); + + // Ensure we have a copy + skillBeginEvent.Value = new SkillContext(); + + TestAdapter adapter = new TestAdapter() + .Use(new SkillMiddleware(_userState)); + + var testFlow = new TestFlow(adapter, async (context, cancellationToken) => + { + // Validate that SkillContext has been populated by the SKillMiddleware correctly + await ValidateSkillContextData(context, new SkillContext()); + }); + + await testFlow.Test(new Activity[] { skillBeginEvent }).StartTestAsync(); + } + + [TestMethod] + public async Task SkillMiddlewareNullSlotData() + { + string jsonSkillBeginActivity = await File.ReadAllTextAsync(@".\TestData\skillBeginEvent.json"); + var skillBeginEvent = JsonConvert.DeserializeObject(jsonSkillBeginActivity); + + skillBeginEvent.Value = null; + + TestAdapter adapter = new TestAdapter() + .Use(new SkillMiddleware(_userState)); + + var testFlow = new TestFlow(adapter, async (context, cancellationToken) => + { + }); + + await testFlow.Test(new Activity[] { skillBeginEvent }).StartTestAsync(); + } + + [TestMethod] + public async Task SkillMiddlewareNullEventName() + { + string jsonSkillBeginActivity = await File.ReadAllTextAsync(@".\TestData\skillBeginEvent.json"); + var skillBeginEvent = JsonConvert.DeserializeObject(jsonSkillBeginActivity); + + skillBeginEvent.Name = null; + + TestAdapter adapter = new TestAdapter() + .Use(new SkillMiddleware(_userState)); + + var testFlow = new TestFlow(adapter, async (context, cancellationToken) => + { + }); + + await testFlow.Test(new Activity[] { skillBeginEvent }).StartTestAsync(); + } + + private async Task ValidateSkillContextData(ITurnContext context, Dictionary skillTestDataToValidate) + { + var accessor = _userState.CreateProperty(nameof(SkillContext)); + var skillContext = await _skillContextAccessor.GetAsync(context, () => new SkillContext()); + + Assert.IsTrue( + skillContext.SequenceEqual(skillTestDataToValidate), + $"SkillContext didn't contain the expected data after Skill middleware processing: {CreateCollectionMismatchMessage(skillContext, skillTestDataToValidate)} "); + } + + private string CreateCollectionMismatchMessage (SkillContext context, Dictionary test) + { + var contextData = string.Join(",", context.Select(x => x.Key + "=" + x.Value)); + var testData = string.Join(",", test.Select(x => x.Key + "=" + x.Value)); + + return $"Expected: {testData}, Actual: {contextData}"; + } + } +} diff --git a/lib/csharp/microsoft.bot.builder.skills/Microsoft.Bot.Builder.Skills/SkillContext.cs b/lib/csharp/microsoft.bot.builder.skills/Microsoft.Bot.Builder.Skills/SkillContext.cs index d4687a3512..e1bf63de6c 100644 --- a/lib/csharp/microsoft.bot.builder.skills/Microsoft.Bot.Builder.Skills/SkillContext.cs +++ b/lib/csharp/microsoft.bot.builder.skills/Microsoft.Bot.Builder.Skills/SkillContext.cs @@ -7,40 +7,15 @@ namespace Microsoft.Bot.Builder.Skills /// /// Context to share state between Bots and Skills. /// - public class SkillContext + public class SkillContext : Dictionary { - private readonly Dictionary _contextStorage = new Dictionary(); - public SkillContext() { } - public SkillContext(Dictionary data) - { - _contextStorage = data; - } - - public int Count - { - get { return _contextStorage.Count; } - } - - public object this[string name] - { - get - { - return _contextStorage[name]; - } - - set - { - _contextStorage[name] = value; - } - } - - public bool TryGetValue(string key, out object value) + public SkillContext(IDictionary collection) + : base(collection) { - return _contextStorage.TryGetValue(key, out value); } } } diff --git a/lib/csharp/microsoft.bot.builder.skills/Microsoft.Bot.Builder.Skills/SkillDialog.cs b/lib/csharp/microsoft.bot.builder.skills/Microsoft.Bot.Builder.Skills/SkillDialog.cs index d93d309d42..355e125e38 100644 --- a/lib/csharp/microsoft.bot.builder.skills/Microsoft.Bot.Builder.Skills/SkillDialog.cs +++ b/lib/csharp/microsoft.bot.builder.skills/Microsoft.Bot.Builder.Skills/SkillDialog.cs @@ -25,7 +25,7 @@ namespace Microsoft.Bot.Builder.Skills /// public class SkillDialog : ComponentDialog { - protected HttpClient _httpClient = new HttpClient(); + private HttpClient _httpClient = new HttpClient(); private readonly MultiProviderAuthDialog _authDialog; private MicrosoftAppCredentialsEx _microsoftAppCredentialsEx; private IBotTelemetryClient _telemetryClient; @@ -44,7 +44,7 @@ public class SkillDialog : ComponentDialog /// Proactive State. /// Endpoint Service. /// Telemetry Client. - /// UserState. + /// User State. /// Auth Dialog. public SkillDialog(SkillManifest skillManifest, ResponseManager responseManager, MicrosoftAppCredentialsEx microsoftAppCredentialsEx, IBotTelemetryClient telemetryClient, UserState userState, MultiProviderAuthDialog authDialog = null) : base(skillManifest.Id) @@ -62,6 +62,9 @@ public SkillDialog(SkillManifest skillManifest, ResponseManager responseManager, } } + // Protected to enable mocking + protected HttpClient HttpClient { get => _httpClient; set => _httpClient = value; } + /// /// When a SkillDialog is started, a skillBegin event is sent which firstly indicates the Skill is being invoked in Skill mode, also slots are also provided where the information exists in the parent Bot. /// @@ -71,7 +74,7 @@ public SkillDialog(SkillManifest skillManifest, ResponseManager responseManager, /// dialog turn result. protected override async Task OnBeginDialogAsync(DialogContext innerDc, object options, CancellationToken cancellationToken = default(CancellationToken)) { - Dictionary slotsToPass = new Dictionary(); + SkillContext slots = new SkillContext(); // Retrieve the SkillContext state object to identify slots (parameters) that can be used to slot-fill when invoking the skill var accessor = _userState.CreateProperty(nameof(SkillContext)); @@ -96,7 +99,7 @@ public SkillDialog(SkillManifest skillManifest, ResponseManager responseManager, // For each slot we check to see if there is an exact match, if so we pass this slot across to the skill if (skillContext.TryGetValue(slot.Name, out object slotValue)) { - slotsToPass.Add(slot.Name, slotValue); + slots.Add(slot.Name, slotValue); } } } @@ -104,7 +107,7 @@ public SkillDialog(SkillManifest skillManifest, ResponseManager responseManager, else { // Loosening checks for current Dispatch evaluation, TODO - Review - //throw new ArgumentException($"Passed Action ({actionName}) could not be found within the {_skillManifest.Id} skill manifest action definition."); + // throw new ArgumentException($"Passed Action ({actionName}) could not be found within the {_skillManifest.Id} skill manifest action definition."); } } @@ -117,7 +120,7 @@ public SkillDialog(SkillManifest skillManifest, ResponseManager responseManager, recipient: new ChannelAccount(id: activity.Recipient.Id, name: activity.Recipient.Name), conversation: new ConversationAccount(id: activity.Conversation.Id), name: SkillEvents.SkillBeginEventName, - value: slotsToPass); + value: slots); // Send skillBegin event to Skill/Bot return await ForwardToSkill(innerDc, skillBeginEvent); diff --git a/lib/csharp/microsoft.bot.builder.skills/Microsoft.Bot.Builder.Skills/SkillException.cs b/lib/csharp/microsoft.bot.builder.skills/Microsoft.Bot.Builder.Skills/SkillException.cs index 629cdfb1a2..425cedbe23 100644 --- a/lib/csharp/microsoft.bot.builder.skills/Microsoft.Bot.Builder.Skills/SkillException.cs +++ b/lib/csharp/microsoft.bot.builder.skills/Microsoft.Bot.Builder.Skills/SkillException.cs @@ -17,7 +17,7 @@ public enum SkillExceptionType /// /// Other types of exceptions /// - Other + Other, } public class SkillException : Exception diff --git a/lib/csharp/microsoft.bot.builder.skills/Microsoft.Bot.Builder.Skills/SkillMiddleware.cs b/lib/csharp/microsoft.bot.builder.skills/Microsoft.Bot.Builder.Skills/SkillMiddleware.cs index 1d71f8c703..d35dcafa91 100644 --- a/lib/csharp/microsoft.bot.builder.skills/Microsoft.Bot.Builder.Skills/SkillMiddleware.cs +++ b/lib/csharp/microsoft.bot.builder.skills/Microsoft.Bot.Builder.Skills/SkillMiddleware.cs @@ -3,6 +3,7 @@ using System.Threading.Tasks; using Microsoft.Bot.Builder.Skills.Models; using Microsoft.Bot.Schema; +using Newtonsoft.Json; namespace Microsoft.Bot.Builder.Skills { @@ -22,12 +23,11 @@ public SkillMiddleware(UserState userState) { // The skillBegin event signals the start of a skill conversation to a Bot. var activity = turnContext.Activity; - if (activity != null && activity.Type == ActivityTypes.Event && activity?.Name == SkillEvents.SkillBeginEventName) + if (activity != null && activity.Type == ActivityTypes.Event && activity.Name == SkillEvents.SkillBeginEventName && activity.Value != null) { - if (activity.Value is Dictionary slotData) + var skillContext = activity.Value as SkillContext; + if (skillContext != null) { - // If we have slotData then we create the SkillContext object within UserState for the skill to access - SkillContext skillContext = new SkillContext(slotData); var accessor = _userState.CreateProperty(nameof(SkillContext)); await accessor.SetAsync(turnContext, skillContext); } diff --git a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Extensions/DateTimeExTests.cs b/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Extensions/DateTimeExTests.cs index da4f9f9920..0968e4e5d0 100644 --- a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Extensions/DateTimeExTests.cs +++ b/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Extensions/DateTimeExTests.cs @@ -117,11 +117,17 @@ public DateTimeTestData(string culture) { Culture = new CultureInfo(culture); } + public CultureInfo Culture { get; } + public DateTime InputDateTime { get; set; } + public string ExpectedDateSpeech { get; set; } + public string ExpectedDateSpeechWithSuffix { get; set; } + public string ExpectedTimeSpeech { get; set; } + public string ExpectedTimeSpeechWithSuffix { get; set; } } } diff --git a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Extensions/ListExTests.cs b/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Extensions/ListExTests.cs index d78bb436a3..757b95b055 100644 --- a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Extensions/ListExTests.cs +++ b/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Extensions/ListExTests.cs @@ -39,6 +39,7 @@ public void ToSpeechString() private class SomeComplexType { public string Number { get; set; } + public object SomeOtherProperty { get; set; } } } diff --git a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Microsoft.Bot.Builder.Solutions.Tests.csproj b/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Microsoft.Bot.Builder.Solutions.Tests.csproj index 4c9f7dfeea..420a17ec7b 100644 --- a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Microsoft.Bot.Builder.Solutions.Tests.csproj +++ b/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Microsoft.Bot.Builder.Solutions.Tests.csproj @@ -7,88 +7,14 @@ - - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - + + + - - True - True - SampleAuthResponses.tt - + + @@ -106,22 +32,6 @@ TextTemplatingFileGenerator TestResponses.cs - - TextTemplatingFileGenerator - SampleAuthResponses.cs - - - TextTemplatingFileGenerator - MainResponses.cs - - - TextTemplatingFileGenerator - SampleResponses.cs - - - TextTemplatingFileGenerator - SharedResponses.cs - @@ -134,47 +44,6 @@ True TestResponses.tt - - True - True - SampleAuthResponses.tt - - - True - True - MainResponses.tt - - - True - True - SampleResponses.tt - - - True - True - SharedResponses.tt - - - True - True - GeneralUtterances.resx - - - True - True - SampleDialogUtterances.resx - - - - - - PublicResXFileCodeGenerator - GeneralUtterances.Designer.cs - - - PublicResXFileCodeGenerator - SampleDialogUtterances.Designer.cs - diff --git a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Auth/AuthDialog.cs b/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Auth/AuthDialog.cs deleted file mode 100644 index f20b68194b..0000000000 --- a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Auth/AuthDialog.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System.Threading; -using System.Threading.Tasks; -using Microsoft.Bot.Builder; -using Microsoft.Bot.Builder.Dialogs; -using Microsoft.Bot.Builder.Solutions.Skills; -using FakeSkill.Dialogs.Shared; -using FakeSkill.ServiceClients; -using Microsoft.Bot.Builder.Solutions.Responses; - -namespace FakeSkill.Dialogs.Auth -{ - public class AuthDialog : SkillTemplateDialog - { - public AuthDialog( - SkillConfigurationBase services, - ResponseManager responseManager, - IStatePropertyAccessor conversationStateAccessor, - IStatePropertyAccessor userStateAccessor, - IServiceManager serviceManager, - IBotTelemetryClient telemetryClient) - : base(nameof(AuthDialog), services, responseManager, conversationStateAccessor, userStateAccessor, serviceManager, telemetryClient) - { - var sample = new WaterfallStep[] - { - GetAuthToken, - End, - }; - - AddDialog(new WaterfallDialog(nameof(AuthDialog), sample)); - } - - private Task End(WaterfallStepContext stepContext, CancellationToken cancellationToken) - { - return stepContext.EndDialogAsync(); - } - - private class DialogIds - { - } - } -} diff --git a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Auth/Resources/SampleAuthResponses.cs b/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Auth/Resources/SampleAuthResponses.cs deleted file mode 100644 index 7796c4dfe8..0000000000 --- a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Auth/Resources/SampleAuthResponses.cs +++ /dev/null @@ -1,18 +0,0 @@ -// https://docs.microsoft.com/en-us/visualstudio/modeling/t4-include-directive?view=vs-2017 -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using Microsoft.Bot.Builder.Solutions.Responses; - -namespace Microsoft.Bot.Builder.Solutions.Tests.Skills.Fakes.FakeSkill.Dialogs.Auth.Resources -{ - /// - /// Contains bot responses. - /// - public class SampleAuthResponses : IResponseIdCollection - { - // Generated accessors - public const string MessagePrompt = "MessagePrompt"; - public const string MessageResponse = "MessageResponse"; - } -} diff --git a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Auth/Resources/SampleAuthResponses.de.json b/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Auth/Resources/SampleAuthResponses.de.json deleted file mode 100644 index b878da9ab0..0000000000 Binary files a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Auth/Resources/SampleAuthResponses.de.json and /dev/null differ diff --git a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Auth/Resources/SampleAuthResponses.es.json b/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Auth/Resources/SampleAuthResponses.es.json deleted file mode 100644 index 4b91a452ff..0000000000 Binary files a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Auth/Resources/SampleAuthResponses.es.json and /dev/null differ diff --git a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Auth/Resources/SampleAuthResponses.fr.json b/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Auth/Resources/SampleAuthResponses.fr.json deleted file mode 100644 index 24856d5f06..0000000000 Binary files a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Auth/Resources/SampleAuthResponses.fr.json and /dev/null differ diff --git a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Auth/Resources/SampleAuthResponses.it.json b/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Auth/Resources/SampleAuthResponses.it.json deleted file mode 100644 index e8f6e499a0..0000000000 Binary files a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Auth/Resources/SampleAuthResponses.it.json and /dev/null differ diff --git a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Auth/Resources/SampleAuthResponses.json b/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Auth/Resources/SampleAuthResponses.json deleted file mode 100644 index 71c9a251c5..0000000000 --- a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Auth/Resources/SampleAuthResponses.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "MessagePrompt": { - "replies": [ - { - "text": "Please type your message.", - "speak": "Please type your message." - }, - { - "text": "Try saying something for this dialog.", - "speak": "Try saying something for this dialog." - } - ], - "inputHint": "expectingInput" - }, - "MessageResponse": { - "replies": [ - { - "text": "You said: {Message}", - "speak": "You said: {Message}" - } - ], - "inputHint": "acceptingInput" - } -} diff --git a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Auth/Resources/SampleAuthResponses.tt b/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Auth/Resources/SampleAuthResponses.tt deleted file mode 100644 index d636d96c8b..0000000000 --- a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Auth/Resources/SampleAuthResponses.tt +++ /dev/null @@ -1,3 +0,0 @@ -<#@ template debug="false" hostspecific="true" language="C#" #> -<#@ output extension=".cs" #> -<#@ include file="..\..\Shared\Resources\ResponseIdCollection.t4"#> diff --git a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Auth/Resources/SampleAuthResponses.zh.json b/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Auth/Resources/SampleAuthResponses.zh.json deleted file mode 100644 index 44c91b5ec1..0000000000 --- a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Auth/Resources/SampleAuthResponses.zh.json +++ /dev/null @@ -1,211 +0,0 @@ -{ - "DidntUnderstandMessage": { - "replies": [ - { - "text": "对不起,没有明白你的意思。", - "speak": "对不起,没有明白你的意思。" - }, - { - "text": "我没有明白你的意思,你能以不同的方式尝试吗?", - "speak": "我没有明白你的意思,你能以不同的方式尝试吗?" - }, - { - "text": "你能以不同的方式说出来吗?", - "speak": "你能以不同的方式说出来吗?" - }, - { - "text": "你能再试一次问我,我没听懂你的意思。", - "speak": "你能再试一次问我,我没听懂你的意思。" - } - ], - "inputHint": "acceptingInput" - }, - "NoAuth": { - "replies": [ - { - "text": "请登录,以便我采取进一步行动。", - "speak": "请登录,以便我采取进一步行动。" - } - ], - "inputHint": "expectingInput" - }, - "AuthFailed": { - "replies": [ - { - "text": "您的登录失败,请稍后再试。", - "speak": "您的登录失败,请稍后再试。" - } - ], - "inputHint": "acceptingInput" - }, - "CancellingMessage": { - "replies": [ - { - "text": "当然,我们可以稍后再做。", - "speak": "当然,我们可以稍后再做。" - } - ], - "inputHint": "acceptingInput" - }, - "ActionEnded": { - "replies": [ - { - "text": "还有什么需要我的帮助吗?", - "speak": "还有什么需要我的帮助吗?" - }, - { - "text": "还有什么我可以帮你的吗?", - "speak": "还有什么我可以帮你的吗?" - }, - { - "text": "还有什么想要采取行动吗?", - "speak": "还有什么想要采取行动吗?" - }, - { - "text": "如果您需要我的帮助,请告诉我。", - "speak": "如果您需要我的帮助,请告诉我。" - }, - { - "text": "如果你需要我的帮助,我就在这里。", - "speak": "如果你需要我的帮助,我就在这里。" - } - ], - "inputHint": "acceptingInput" - }, - "ToDoErrorMessage": { - "replies": [ - { - "text": "对不起,看起来出了问题!", - "speak": "对不起,看起来出了问题!" - }, - { - "text": "发生错误,给我一些时间,稍后再试。", - "speak": "发生错误,给我一些时间,稍后再试。" - }, - { - "text": "出了点问题,对不起!", - "speak": "出了点问题,对不起!" - }, - { - "text": "我相信出了点问题。你稍后可以再试一次吗?", - "speak": "我相信出了点问题。你稍后可以再试一次吗?" - }, - { - "text": "抱歉,我现在找不到你想要的东西。请稍后再试。", - "speak": "抱歉,我现在找不到你想要的东西。请稍后再试。" - } - ], - "inputHint": "acceptingInput" - }, - "ToDoErrorMessage_BotProblem": { - "replies": [ - { - "text": "对不起,出了点问题。开发人员已经收到通知并且在解决这个问题。你很快就又可以正常使用这个功能了。", - "speak": "对不起,出了点问题。开发人员已经收到通知并且在解决这个问题。你很快就又可以正常使用这个功能了。" - } - ], - "inputHint": "acceptingInput" - }, - "SettingUpOneNoteMessage": { - "replies": [ - { - "text": "我注意到你还没有OneNote, 我正在为您创建,包含一个待办事项列表,一个购物列表以及一个杂货列表。", - "speak": "我注意到你还没有OneNote, 我正在为您创建,包含一个待办事项列表,一个购物列表以及一个杂货列表。" - } - ], - "inputHint": "ignoringInput" - }, - "AfterOneNoteSetupMessage": { - "replies": [ - { - "text": "设置完成,我已经给你发送带有OneNote链接的邮件,现在可以记录你的任务了。", - "speak": "设置完成,我已经给你发送带有OneNote链接的邮件,现在可以记录你的任务了。" - } - ], - "inputHint": "ignoringInput" - }, - "SettingUpOutlookMessage": { - "replies": [ - { - "text": "我注意到你还没有Outlook任务簿, 我正在为您创建,包含一个待办事项列表,一个购物列表以及一个杂货列表。", - "speak": "我注意到你还没有Outlook任务簿, 我正在为您创建,包含一个待办事项列表,一个购物列表以及一个杂货列表。" - } - ], - "inputHint": "ignoringInput" - }, - "AfterOutlookSetupMessage": { - "replies": [ - { - "text": "设置完成,我已经给你发送带有Outlook任务簿链接的邮件,现在可以记录你的任务了。", - "speak": "设置完成,我已经给你发送带有Outlook任务簿链接的邮件,现在可以记录你的任务了。" - } - ], - "inputHint": "ignoringInput" - }, - "ShowToDoTasks": { - "replies": [ - { - "text": "您的{listType}列表有{taskCount}个任务:", - "speak": "您的{listType}列表有{taskCount}个任务:" - } - ], - "inputHint": "ignoringInput" - }, - "AskToDoTaskIndex": { - "replies": [ - { - "text": "您想为这个操作选择哪个任务?", - "speak": "您想为这个操作选择哪个任务?" - } - ], - "inputHint": "expectingInput" - }, - "AskToDoContentText": { - "replies": [ - { - "text": "当然。您想加入什么到事项表?", - "speak": "当然。您想加入什么到待办事项表?" - }, - { - "text": "好的,您想加入什么到事项表?", - "speak": "好的,您想加入什么到事项表?" - }, - { - "text": "好,您想加入什么到事项表?", - "speak": "好,您想加入什么到事项表?" - }, - { - "text": "您想加入什么到事项表?", - "speak": "您想加入什么到事项表?" - } - ], - "inputHint": "expectingInput" - }, - "AfterToDoTaskAdded": { - "replies": [ - { - "text": "已经为您加入此任务。", - "speak": "已经为您加入此任务。" - } - ], - "inputHint": "acceptingInput" - }, - "NoTasksInList": { - "replies": [ - { - "text": "您的事项表是空的.", - "speak": "您的事项表是空的." - } - ], - "inputHint": "acceptingInput" - }, - "SwitchListType": { - "replies": [ - { - "text": "这看起来像是{listType}列表的任务。你想要把它加入到{listType}列表吗?", - "speak": "这看起来像是{listType}列表的任务。你想要把它加入到{listType}列表吗?" - } - ], - "inputHint": "expectingInput" - } -} diff --git a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Main/MainDialog.cs b/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Main/MainDialog.cs deleted file mode 100644 index 71da10343a..0000000000 --- a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Main/MainDialog.cs +++ /dev/null @@ -1,287 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Threading; -using System.Threading.Tasks; -using Luis; -using Microsoft.Bot.Builder; -using Microsoft.Bot.Builder.Dialogs; -using Microsoft.Bot.Schema; -using Microsoft.Bot.Builder.Solutions.Dialogs; -using Microsoft.Bot.Builder.Solutions.Skills; -using FakeSkill.Dialogs.Sample; -using FakeSkill.Dialogs.Shared.DialogOptions; -using FakeSkill.ServiceClients; -using FakeSkill.Dialogs.Auth; -using Microsoft.Bot.Builder.Solutions.Responses; -using Microsoft.Bot.Builder.Solutions.Tests.Skills.Fakes.FakeSkill.Dialogs.Main.Resources; -using Microsoft.Bot.Builder.Solutions.Tests.Skills.Fakes.FakeSkill.Dialogs.Shared.Resources; - -namespace FakeSkill.Dialogs.Main -{ - public class MainDialog : RouterDialog - { - private bool _skillMode; - private SkillConfigurationBase _services; - private ResponseManager _responseManager; - private UserState _userState; - private ConversationState _conversationState; - private IServiceManager _serviceManager; - private IStatePropertyAccessor _conversationStateAccessor; - private IStatePropertyAccessor _userStateAccessor; - - public MainDialog( - SkillConfigurationBase services, - ResponseManager responseManager, - ConversationState conversationState, - UserState userState, - IBotTelemetryClient telemetryClient, - IServiceManager serviceManager, - bool skillMode) - : base(nameof(MainDialog), telemetryClient) - { - _skillMode = skillMode; - _services = services; - _responseManager = responseManager; - _conversationState = conversationState; - _userState = userState; - _serviceManager = serviceManager; - TelemetryClient = telemetryClient; - - // Initialize state accessor - _conversationStateAccessor = _conversationState.CreateProperty(nameof(SkillConversationState)); - _userStateAccessor = _userState.CreateProperty(nameof(SkillUserState)); - - // RegisterDialogs - RegisterDialogs(); - } - - protected override async Task OnStartAsync(DialogContext dc, CancellationToken cancellationToken = default(CancellationToken)) - { - if (!_skillMode) - { - // send a greeting if we're in local mode - await dc.Context.SendActivityAsync(_responseManager.GetResponse(MainResponses.WelcomeMessage)); - } - } - - protected override async Task RouteAsync(DialogContext dc, CancellationToken cancellationToken = default(CancellationToken)) - { - var state = await _conversationStateAccessor.GetAsync(dc.Context, () => new SkillConversationState()); - - // get current activity locale - var locale = CultureInfo.CurrentUICulture.TwoLetterISOLanguageName; - var localeConfig = _services.LocaleConfigurations[locale]; - - // Get skill LUIS model from configuration - localeConfig.LuisServices.TryGetValue("FakeSkill", out var luisService); - - if (luisService == null) - { - throw new Exception("The specified LUIS Model could not be found in your Bot Services configuration."); - } - else - { - var skillOptions = new SkillTemplateDialogOptions - { - SkillMode = _skillMode, - }; - - var result = await luisService.RecognizeAsync(dc.Context, CancellationToken.None); - var intent = result?.TopIntent().intent; - - switch (intent) - { - case FakeSkillLU.Intent.Sample: - { - await dc.BeginDialogAsync(nameof(SampleDialog), skillOptions); - break; - } - - case FakeSkillLU.Intent.Auth: - { - await dc.BeginDialogAsync(nameof(AuthDialog), skillOptions); - break; - } - - case FakeSkillLU.Intent.None: - { - // No intent was identified, send confused message - await dc.Context.SendActivityAsync(_responseManager.GetResponse(SharedResponses.DidntUnderstandMessage)); - if (_skillMode) - { - await CompleteAsync(dc); - } - - break; - } - - default: - { - // intent was identified but not yet implemented - await dc.Context.SendActivityAsync(_responseManager.GetResponse(MainResponses.FeatureNotAvailable)); - if (_skillMode) - { - await CompleteAsync(dc); - } - - break; - } - } - } - } - - protected override async Task CompleteAsync(DialogContext dc, DialogTurnResult result = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (_skillMode) - { - var response = dc.Context.Activity.CreateReply(); - response.Type = ActivityTypes.EndOfConversation; - - await dc.Context.SendActivityAsync(response); - } - - // End active dialog - await dc.EndDialogAsync(result); - } - - protected override async Task OnEventAsync(DialogContext dc, CancellationToken cancellationToken = default(CancellationToken)) - { - switch (dc.Context.Activity.Name) - { - case Events.SkillBeginEvent: - { - var state = await _conversationStateAccessor.GetAsync(dc.Context, () => new SkillConversationState()); - - if (dc.Context.Activity.Value is Dictionary userData) - { - // Capture user data from event if needed - } - - break; - } - - case Events.TokenResponseEvent: - { - // Auth dialog completion - var result = await dc.ContinueDialogAsync(); - - // If the dialog completed when we sent the token, end the skill conversation - if (result.Status != DialogTurnStatus.Waiting) - { - var response = dc.Context.Activity.CreateReply(); - response.Type = ActivityTypes.EndOfConversation; - - await dc.Context.SendActivityAsync(response); - } - - break; - } - } - } - - protected override async Task OnInterruptDialogAsync(DialogContext dc, CancellationToken cancellationToken = default(CancellationToken)) - { - var result = InterruptionAction.NoAction; - - if (dc.Context.Activity.Type == ActivityTypes.Message) - { - // get current activity locale - var locale = CultureInfo.CurrentUICulture.TwoLetterISOLanguageName; - var localeConfig = _services.LocaleConfigurations[locale]; - - // check general luis intent - localeConfig.LuisServices.TryGetValue("general", out var luisService); - - if (luisService == null) - { - throw new Exception("The specified LUIS Model could not be found in your Skill configuration."); - } - else - { - var luisResult = await luisService.RecognizeAsync(dc.Context, cancellationToken); - var topIntent = luisResult.TopIntent().intent; - - switch (topIntent) - { - case General.Intent.Cancel: - { - result = await OnCancel(dc); - break; - } - - case General.Intent.Help: - { - result = await OnHelp(dc); - break; - } - - case General.Intent.Logout: - { - result = await OnLogout(dc); - break; - } - } - } - } - - return result; - } - - private async Task OnCancel(DialogContext dc) - { - await dc.Context.SendActivityAsync(_responseManager.GetResponse(MainResponses.CancelMessage)); - await CompleteAsync(dc); - await dc.CancelAllDialogsAsync(); - return InterruptionAction.StartedDialog; - } - - private async Task OnHelp(DialogContext dc) - { - await dc.Context.SendActivityAsync(_responseManager.GetResponse(MainResponses.HelpMessage)); - return InterruptionAction.MessageSentToUser; - } - - private async Task OnLogout(DialogContext dc) - { - BotFrameworkAdapter adapter; - var supported = dc.Context.Adapter is BotFrameworkAdapter; - if (!supported) - { - throw new InvalidOperationException("OAuthPrompt.SignOutUser(): not supported by the current adapter"); - } - else - { - adapter = (BotFrameworkAdapter)dc.Context.Adapter; - } - - await dc.CancelAllDialogsAsync(); - - // Sign out user - var tokens = await adapter.GetTokenStatusAsync(dc.Context, dc.Context.Activity.From.Id); - foreach (var token in tokens) - { - await adapter.SignOutUserAsync(dc.Context, token.ConnectionName); - } - - await dc.Context.SendActivityAsync(_responseManager.GetResponse(MainResponses.LogOut)); - - return InterruptionAction.StartedDialog; - } - - private void RegisterDialogs() - { - AddDialog(new SampleDialog(_services, _responseManager, _conversationStateAccessor, _userStateAccessor, _serviceManager, TelemetryClient)); - AddDialog(new AuthDialog(_services, _responseManager, _conversationStateAccessor, _userStateAccessor, _serviceManager, TelemetryClient)); - } - - private class Events - { - public const string TokenResponseEvent = "tokens/response"; - public const string SkillBeginEvent = "skillBegin"; - } - } -} \ No newline at end of file diff --git a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Main/Resources/MainResponses.cs b/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Main/Resources/MainResponses.cs deleted file mode 100644 index 4f16503475..0000000000 --- a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Main/Resources/MainResponses.cs +++ /dev/null @@ -1,23 +0,0 @@ -// https://docs.microsoft.com/en-us/visualstudio/modeling/t4-include-directive?view=vs-2017 -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using Microsoft.Bot.Builder.Solutions.Responses; - -namespace Microsoft.Bot.Builder.Solutions.Tests.Skills.Fakes.FakeSkill.Dialogs.Main.Resources -{ - /// - /// Contains bot responses. - /// - public class MainResponses : IResponseIdCollection - { - // Generated accessors - public const string WelcomeMessage = "WelcomeMessage"; - public const string HelpMessage = "HelpMessage"; - public const string GreetingMessage = "GreetingMessage"; - public const string GoodbyeMessage = "GoodbyeMessage"; - public const string LogOut = "LogOut"; - public const string FeatureNotAvailable = "FeatureNotAvailable"; - public const string CancelMessage = "CancelMessage"; - } -} diff --git a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Main/Resources/MainResponses.de.json b/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Main/Resources/MainResponses.de.json deleted file mode 100644 index 17af113942..0000000000 Binary files a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Main/Resources/MainResponses.de.json and /dev/null differ diff --git a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Main/Resources/MainResponses.es.json b/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Main/Resources/MainResponses.es.json deleted file mode 100644 index d9132efb64..0000000000 Binary files a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Main/Resources/MainResponses.es.json and /dev/null differ diff --git a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Main/Resources/MainResponses.fr.json b/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Main/Resources/MainResponses.fr.json deleted file mode 100644 index eb6ed6999b..0000000000 Binary files a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Main/Resources/MainResponses.fr.json and /dev/null differ diff --git a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Main/Resources/MainResponses.it.json b/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Main/Resources/MainResponses.it.json deleted file mode 100644 index 38ba94faee..0000000000 Binary files a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Main/Resources/MainResponses.it.json and /dev/null differ diff --git a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Main/Resources/MainResponses.json b/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Main/Resources/MainResponses.json deleted file mode 100644 index 2cb741b57f..0000000000 --- a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Main/Resources/MainResponses.json +++ /dev/null @@ -1,83 +0,0 @@ -{ - "WelcomeMessage": { - "replies": [ - { - "text": "[Enter your intro message here]", - "speak": "[Enter your intro message here]" - } - ], - "suggestedActions": [], - "inputHint": "acceptingInput" - }, - "HelpMessage": { - "replies": [ - { - "text": "[Enter your help message here]", - "speak": "[Enter your help message here]" - } - ], - "suggestedActions": [], - "inputHint": "acceptingInput" - }, - "GreetingMessage": { - "replies": [ - { - "text": "Hi!", - "speak": "Hi!" - }, - { - "text": "Hi there!", - "speak": "Hi there!" - }, - { - "text": "Hello!", - "speak": "Hello!" - } - ], - "inputHint": "acceptingInput" - }, - "GoodbyeMessage": { - "replies": [ - { - "text": "Goodbye!", - "speak": "Goodbye!" - } - ], - "inputHint": "acceptingInput" - }, - "LogOut": { - "replies": [ - { - "text": "Your sign out was successful.", - "speak": "Your sign out was successful." - }, - { - "text": "You have successfully signed out.", - "speak": "You have successfully signed out." - }, - { - "text": "You have been logged out.", - "speak": "You have been logged out." - } - ], - "inputHint": "acceptingInput" - }, - "FeatureNotAvailable": { - "replies": [ - { - "text": "This feature is not yet available in this skill. Please try asking something else.", - "speak": "This feature is not yet available in thiskill. Please try asking something else." - } - ], - "inputHint": "acceptingInput" - }, - "CancelMessage": { - "replies": [ - { - "text": "Ok, let's start over.", - "speak": "Ok, let's start over." - } - ], - "inputHint": "acceptingInput" - } -} diff --git a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Main/Resources/MainResponses.tt b/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Main/Resources/MainResponses.tt deleted file mode 100644 index d636d96c8b..0000000000 --- a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Main/Resources/MainResponses.tt +++ /dev/null @@ -1,3 +0,0 @@ -<#@ template debug="false" hostspecific="true" language="C#" #> -<#@ output extension=".cs" #> -<#@ include file="..\..\Shared\Resources\ResponseIdCollection.t4"#> diff --git a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Main/Resources/MainResponses.zh.json b/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Main/Resources/MainResponses.zh.json deleted file mode 100644 index 647d005144..0000000000 --- a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Main/Resources/MainResponses.zh.json +++ /dev/null @@ -1,82 +0,0 @@ -{ - "WelcomeMessage": { - "replies": [ - { - "text": "[在此输入您的简介信息]", - "speak": "[在此输入您的简介信息]" - } - ], - "inputHint": "acceptingInput" - }, - "HelpMessage": { - "replies": [ - { - "text": "[在此处输入您的帮助信息]", - "speak": "[在此处输入您的帮助信息]" - } - ], - "suggestedActions": [], - "inputHint": "acceptingInput" - }, - "GreetingMessage": { - "replies": [ - { - "text": "嗨!", - "speak": "嗨!" - }, - { - "text": "我在这!", - "speak": "我在这!" - }, - { - "text": "你好!", - "speak": "你好!" - }, - { - "text": "您好!", - "speak": "您好!" - } - ], - "inputHint": "acceptingInput" - }, - "GoodbyeMessage": { - "replies": [ - { - "text": "再见!", - "speak": "再见!" - } - ], - "inputHint": "acceptingInput" - }, - "LogOut": { - "replies": [ - { - "text": "您已成功退出。", - "speak": "您已成功退出。" - }, - { - "text": "您已退出。", - "speak": "您已退出。" - } - ], - "inputHint": "acceptingInput" - }, - "FeatureNotAvailable": { - "replies": [ - { - "text": "此功能在此技能中尚不可用。", - "speak": "此功能在此技能中尚不可用。" - } - ], - "inputHint": "acceptingInput" - }, - "CancelMessage": { - "replies": [ - { - "text": "好的, 我们从头再来。", - "speak": "好的, 我们从头再来。" - } - ], - "inputHint": "acceptingInput" - } -} diff --git a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Sample/Resources/SampleResponses.cs b/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Sample/Resources/SampleResponses.cs deleted file mode 100644 index af90d5dd3d..0000000000 --- a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Sample/Resources/SampleResponses.cs +++ /dev/null @@ -1,18 +0,0 @@ -// https://docs.microsoft.com/en-us/visualstudio/modeling/t4-include-directive?view=vs-2017 -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using Microsoft.Bot.Builder.Solutions.Responses; - -namespace Microsoft.Bot.Builder.Solutions.Tests.Skills.Fakes.FakeSkill.Dialogs.Sample.Resources -{ - /// - /// Contains bot responses. - /// - public class SampleResponses : IResponseIdCollection - { - // Generated accessors - public const string MessagePrompt = "MessagePrompt"; - public const string MessageResponse = "MessageResponse"; - } -} diff --git a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Sample/Resources/SampleResponses.de.json b/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Sample/Resources/SampleResponses.de.json deleted file mode 100644 index b878da9ab0..0000000000 Binary files a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Sample/Resources/SampleResponses.de.json and /dev/null differ diff --git a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Sample/Resources/SampleResponses.es.json b/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Sample/Resources/SampleResponses.es.json deleted file mode 100644 index 4b91a452ff..0000000000 Binary files a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Sample/Resources/SampleResponses.es.json and /dev/null differ diff --git a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Sample/Resources/SampleResponses.fr.json b/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Sample/Resources/SampleResponses.fr.json deleted file mode 100644 index 24856d5f06..0000000000 Binary files a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Sample/Resources/SampleResponses.fr.json and /dev/null differ diff --git a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Sample/Resources/SampleResponses.it.json b/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Sample/Resources/SampleResponses.it.json deleted file mode 100644 index e8f6e499a0..0000000000 Binary files a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Sample/Resources/SampleResponses.it.json and /dev/null differ diff --git a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Sample/Resources/SampleResponses.json b/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Sample/Resources/SampleResponses.json deleted file mode 100644 index 71c9a251c5..0000000000 --- a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Sample/Resources/SampleResponses.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "MessagePrompt": { - "replies": [ - { - "text": "Please type your message.", - "speak": "Please type your message." - }, - { - "text": "Try saying something for this dialog.", - "speak": "Try saying something for this dialog." - } - ], - "inputHint": "expectingInput" - }, - "MessageResponse": { - "replies": [ - { - "text": "You said: {Message}", - "speak": "You said: {Message}" - } - ], - "inputHint": "acceptingInput" - } -} diff --git a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Sample/Resources/SampleResponses.tt b/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Sample/Resources/SampleResponses.tt deleted file mode 100644 index d636d96c8b..0000000000 --- a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Sample/Resources/SampleResponses.tt +++ /dev/null @@ -1,3 +0,0 @@ -<#@ template debug="false" hostspecific="true" language="C#" #> -<#@ output extension=".cs" #> -<#@ include file="..\..\Shared\Resources\ResponseIdCollection.t4"#> diff --git a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Sample/Resources/SampleResponses.zh.json b/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Sample/Resources/SampleResponses.zh.json deleted file mode 100644 index 44c91b5ec1..0000000000 --- a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Sample/Resources/SampleResponses.zh.json +++ /dev/null @@ -1,211 +0,0 @@ -{ - "DidntUnderstandMessage": { - "replies": [ - { - "text": "对不起,没有明白你的意思。", - "speak": "对不起,没有明白你的意思。" - }, - { - "text": "我没有明白你的意思,你能以不同的方式尝试吗?", - "speak": "我没有明白你的意思,你能以不同的方式尝试吗?" - }, - { - "text": "你能以不同的方式说出来吗?", - "speak": "你能以不同的方式说出来吗?" - }, - { - "text": "你能再试一次问我,我没听懂你的意思。", - "speak": "你能再试一次问我,我没听懂你的意思。" - } - ], - "inputHint": "acceptingInput" - }, - "NoAuth": { - "replies": [ - { - "text": "请登录,以便我采取进一步行动。", - "speak": "请登录,以便我采取进一步行动。" - } - ], - "inputHint": "expectingInput" - }, - "AuthFailed": { - "replies": [ - { - "text": "您的登录失败,请稍后再试。", - "speak": "您的登录失败,请稍后再试。" - } - ], - "inputHint": "acceptingInput" - }, - "CancellingMessage": { - "replies": [ - { - "text": "当然,我们可以稍后再做。", - "speak": "当然,我们可以稍后再做。" - } - ], - "inputHint": "acceptingInput" - }, - "ActionEnded": { - "replies": [ - { - "text": "还有什么需要我的帮助吗?", - "speak": "还有什么需要我的帮助吗?" - }, - { - "text": "还有什么我可以帮你的吗?", - "speak": "还有什么我可以帮你的吗?" - }, - { - "text": "还有什么想要采取行动吗?", - "speak": "还有什么想要采取行动吗?" - }, - { - "text": "如果您需要我的帮助,请告诉我。", - "speak": "如果您需要我的帮助,请告诉我。" - }, - { - "text": "如果你需要我的帮助,我就在这里。", - "speak": "如果你需要我的帮助,我就在这里。" - } - ], - "inputHint": "acceptingInput" - }, - "ToDoErrorMessage": { - "replies": [ - { - "text": "对不起,看起来出了问题!", - "speak": "对不起,看起来出了问题!" - }, - { - "text": "发生错误,给我一些时间,稍后再试。", - "speak": "发生错误,给我一些时间,稍后再试。" - }, - { - "text": "出了点问题,对不起!", - "speak": "出了点问题,对不起!" - }, - { - "text": "我相信出了点问题。你稍后可以再试一次吗?", - "speak": "我相信出了点问题。你稍后可以再试一次吗?" - }, - { - "text": "抱歉,我现在找不到你想要的东西。请稍后再试。", - "speak": "抱歉,我现在找不到你想要的东西。请稍后再试。" - } - ], - "inputHint": "acceptingInput" - }, - "ToDoErrorMessage_BotProblem": { - "replies": [ - { - "text": "对不起,出了点问题。开发人员已经收到通知并且在解决这个问题。你很快就又可以正常使用这个功能了。", - "speak": "对不起,出了点问题。开发人员已经收到通知并且在解决这个问题。你很快就又可以正常使用这个功能了。" - } - ], - "inputHint": "acceptingInput" - }, - "SettingUpOneNoteMessage": { - "replies": [ - { - "text": "我注意到你还没有OneNote, 我正在为您创建,包含一个待办事项列表,一个购物列表以及一个杂货列表。", - "speak": "我注意到你还没有OneNote, 我正在为您创建,包含一个待办事项列表,一个购物列表以及一个杂货列表。" - } - ], - "inputHint": "ignoringInput" - }, - "AfterOneNoteSetupMessage": { - "replies": [ - { - "text": "设置完成,我已经给你发送带有OneNote链接的邮件,现在可以记录你的任务了。", - "speak": "设置完成,我已经给你发送带有OneNote链接的邮件,现在可以记录你的任务了。" - } - ], - "inputHint": "ignoringInput" - }, - "SettingUpOutlookMessage": { - "replies": [ - { - "text": "我注意到你还没有Outlook任务簿, 我正在为您创建,包含一个待办事项列表,一个购物列表以及一个杂货列表。", - "speak": "我注意到你还没有Outlook任务簿, 我正在为您创建,包含一个待办事项列表,一个购物列表以及一个杂货列表。" - } - ], - "inputHint": "ignoringInput" - }, - "AfterOutlookSetupMessage": { - "replies": [ - { - "text": "设置完成,我已经给你发送带有Outlook任务簿链接的邮件,现在可以记录你的任务了。", - "speak": "设置完成,我已经给你发送带有Outlook任务簿链接的邮件,现在可以记录你的任务了。" - } - ], - "inputHint": "ignoringInput" - }, - "ShowToDoTasks": { - "replies": [ - { - "text": "您的{listType}列表有{taskCount}个任务:", - "speak": "您的{listType}列表有{taskCount}个任务:" - } - ], - "inputHint": "ignoringInput" - }, - "AskToDoTaskIndex": { - "replies": [ - { - "text": "您想为这个操作选择哪个任务?", - "speak": "您想为这个操作选择哪个任务?" - } - ], - "inputHint": "expectingInput" - }, - "AskToDoContentText": { - "replies": [ - { - "text": "当然。您想加入什么到事项表?", - "speak": "当然。您想加入什么到待办事项表?" - }, - { - "text": "好的,您想加入什么到事项表?", - "speak": "好的,您想加入什么到事项表?" - }, - { - "text": "好,您想加入什么到事项表?", - "speak": "好,您想加入什么到事项表?" - }, - { - "text": "您想加入什么到事项表?", - "speak": "您想加入什么到事项表?" - } - ], - "inputHint": "expectingInput" - }, - "AfterToDoTaskAdded": { - "replies": [ - { - "text": "已经为您加入此任务。", - "speak": "已经为您加入此任务。" - } - ], - "inputHint": "acceptingInput" - }, - "NoTasksInList": { - "replies": [ - { - "text": "您的事项表是空的.", - "speak": "您的事项表是空的." - } - ], - "inputHint": "acceptingInput" - }, - "SwitchListType": { - "replies": [ - { - "text": "这看起来像是{listType}列表的任务。你想要把它加入到{listType}列表吗?", - "speak": "这看起来像是{listType}列表的任务。你想要把它加入到{listType}列表吗?" - } - ], - "inputHint": "expectingInput" - } -} diff --git a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Sample/SampleDialog.cs b/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Sample/SampleDialog.cs deleted file mode 100644 index 4da02430b8..0000000000 --- a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Sample/SampleDialog.cs +++ /dev/null @@ -1,65 +0,0 @@ -using System.Collections.Specialized; -using System.Threading; -using System.Threading.Tasks; -using Microsoft.Bot.Builder; -using Microsoft.Bot.Builder.Dialogs; -using Microsoft.Bot.Builder.Solutions.Skills; -using FakeSkill.Dialogs.Shared; -using FakeSkill.ServiceClients; -using Microsoft.Bot.Builder.Solutions.Tests.Skills.Fakes.FakeSkill.Dialogs.Sample.Resources; -using Microsoft.Bot.Builder.Solutions.Responses; - -namespace FakeSkill.Dialogs.Sample -{ - public class SampleDialog : SkillTemplateDialog - { - public SampleDialog( - SkillConfigurationBase services, - ResponseManager responseManager, - IStatePropertyAccessor conversationStateAccessor, - IStatePropertyAccessor userStateAccessor, - IServiceManager serviceManager, - IBotTelemetryClient telemetryClient) - : base(nameof(SampleDialog), services, responseManager, conversationStateAccessor, userStateAccessor, serviceManager, telemetryClient) - { - var sample = new WaterfallStep[] - { - PromptForMessage, - PrintMessage, - End, - }; - - AddDialog(new WaterfallDialog(nameof(SampleDialog), sample)); - AddDialog(new TextPrompt(DialogIds.MessagePrompt)); - } - - private async Task PromptForMessage(WaterfallStepContext stepContext, CancellationToken cancellationToken) - { - var prompt = ResponseManager.GetResponse(SampleResponses.MessagePrompt); - return await stepContext.PromptAsync(DialogIds.MessagePrompt, new PromptOptions { Prompt = prompt }); - } - - private async Task PrintMessage(WaterfallStepContext stepContext, CancellationToken cancellationToken) - { - var tokens = new StringDictionary - { - { "Message", stepContext.Result.ToString() }, - }; - - var response = ResponseManager.GetResponse(SampleResponses.MessageResponse, tokens); - await stepContext.Context.SendActivityAsync(response); - - return await stepContext.NextAsync(); - } - - private Task End(WaterfallStepContext stepContext, CancellationToken cancellationToken) - { - return stepContext.EndDialogAsync(); - } - - private class DialogIds - { - public const string MessagePrompt = "messagePrompt"; - } - } -} diff --git a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Shared/DialogOptions/SkillDialogOptions.cs b/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Shared/DialogOptions/SkillDialogOptions.cs deleted file mode 100644 index 252e6282b6..0000000000 --- a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Shared/DialogOptions/SkillDialogOptions.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace FakeSkill.Dialogs.Shared.DialogOptions -{ - public class SkillTemplateDialogOptions - { - public bool SkillMode { get; set; } - } -} \ No newline at end of file diff --git a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Shared/FakeSkillDialog.cs b/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Shared/FakeSkillDialog.cs deleted file mode 100644 index 6880ea60b7..0000000000 --- a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Shared/FakeSkillDialog.cs +++ /dev/null @@ -1,202 +0,0 @@ -using System; -using System.Threading; -using System.Threading.Tasks; -using Microsoft.Bot.Builder; -using Microsoft.Bot.Builder.Dialogs; -using Microsoft.Bot.Schema; -using Microsoft.Bot.Builder.Solutions.Authentication; -using Microsoft.Bot.Builder.Solutions.Skills; -using Microsoft.Bot.Builder.Solutions.Util; -using Newtonsoft.Json.Linq; -using FakeSkill.Dialogs.Shared.DialogOptions; -using FakeSkill.ServiceClients; -using Microsoft.Bot.Builder.Solutions.Responses; -using Microsoft.Bot.Builder.Solutions.Tests; -using Microsoft.Bot.Builder.Solutions.Telemetry; -using Microsoft.Bot.Builder.Solutions.Tests.Skills.Fakes.FakeSkill.Dialogs.Shared.Resources; - -namespace FakeSkill.Dialogs.Shared -{ - public class SkillTemplateDialog : ComponentDialog - { - public SkillTemplateDialog( - string dialogId, - SkillConfigurationBase services, - ResponseManager responseManager, - IStatePropertyAccessor conversationStateAccessor, - IStatePropertyAccessor userStateAccessor, - IServiceManager serviceManager, - IBotTelemetryClient telemetryClient) - : base(dialogId) - { - Services = services; - ResponseManager = responseManager; - ConversationStateAccessor = conversationStateAccessor; - UserStateAccessor = userStateAccessor; - ServiceManager = serviceManager; - TelemetryClient = telemetryClient; - - // NOTE: Uncomment the following if your skill requires authentication - //if (!Services.AuthenticationConnections.Any()) - //{ - // throw new Exception("You must configure an authentication connection in your bot file before using this component."); - //} - - //AddDialog(new EventPrompt(DialogIds.SkillModeAuth, "tokens/response", TokenResponseValidator)); - //AddDialog(new MultiProviderAuthDialog(services)); - } - - protected SkillConfigurationBase Services { get; set; } - - protected IStatePropertyAccessor ConversationStateAccessor { get; set; } - - protected IStatePropertyAccessor UserStateAccessor { get; set; } - - protected IServiceManager ServiceManager { get; set; } - - protected ResponseManager ResponseManager { get; set; } - - protected override async Task OnBeginDialogAsync(DialogContext dc, object options, CancellationToken cancellationToken = default(CancellationToken)) - { - await DigestLuisResult(dc); - return await base.OnBeginDialogAsync(dc, options, cancellationToken); - } - - protected override async Task OnContinueDialogAsync(DialogContext dc, CancellationToken cancellationToken = default(CancellationToken)) - { - await DigestLuisResult(dc); - return await base.OnContinueDialogAsync(dc, cancellationToken); - } - - // Shared steps - protected async Task GetAuthToken(WaterfallStepContext sc, CancellationToken cancellationToken = default(CancellationToken)) - { - try - { - var skillOptions = (SkillTemplateDialogOptions)sc.Options; - - // If in Skill mode we ask the calling Bot for the token - if (skillOptions != null && skillOptions.SkillMode) - { - // We trigger a Token Request from the Parent Bot by sending a "TokenRequest" event back and then waiting for a "TokenResponse" - // TODO Error handling - if we get a new activity that isn't an event - var response = sc.Context.Activity.CreateReply(); - response.Type = ActivityTypes.Event; - response.Name = "tokens/request"; - - // Send the tokens/request Event - await sc.Context.SendActivityAsync(response); - - // Wait for the tokens/response event - return await sc.PromptAsync(DialogIds.SkillModeAuth, new PromptOptions()); - } - else - { - return await sc.PromptAsync(nameof(MultiProviderAuthDialog), new PromptOptions() { RetryPrompt = ResponseManager.GetResponse(SharedResponses.NoAuth) }); - } - } - catch (Exception ex) - { - await HandleDialogExceptions(sc, ex); - return new DialogTurnResult(DialogTurnStatus.Cancelled, CommonUtil.DialogTurnResultCancelAllDialogs); - } - } - - protected async Task AfterGetAuthToken(WaterfallStepContext sc, CancellationToken cancellationToken = default(CancellationToken)) - { - try - { - // When the user authenticates interactively we pass on the tokens/Response event which surfaces as a JObject - // When the token is cached we get a TokenResponse object. - var skillOptions = (SkillTemplateDialogOptions)sc.Options; - ProviderTokenResponse providerTokenResponse; - if (skillOptions != null && skillOptions.SkillMode) - { - var resultType = sc.Context.Activity.Value.GetType(); - if (resultType == typeof(ProviderTokenResponse)) - { - providerTokenResponse = sc.Context.Activity.Value as ProviderTokenResponse; - } - else - { - var tokenResponseObject = sc.Context.Activity.Value as JObject; - providerTokenResponse = tokenResponseObject?.ToObject(); - } - } - else - { - providerTokenResponse = sc.Result as ProviderTokenResponse; - } - - if (providerTokenResponse != null) - { - var state = await ConversationStateAccessor.GetAsync(sc.Context); - state.Token = providerTokenResponse.TokenResponse.Token; - } - - return await sc.NextAsync(); - } - catch (Exception ex) - { - await HandleDialogExceptions(sc, ex); - return new DialogTurnResult(DialogTurnStatus.Cancelled, CommonUtil.DialogTurnResultCancelAllDialogs); - } - } - - // Validators - protected Task TokenResponseValidator(PromptValidatorContext pc, CancellationToken cancellationToken) - { - var activity = pc.Recognized.Value; - if (activity != null && activity.Type == ActivityTypes.Event) - { - return Task.FromResult(true); - } - else - { - return Task.FromResult(false); - } - } - - protected Task AuthPromptValidator(PromptValidatorContext promptContext, CancellationToken cancellationToken) - { - var token = promptContext.Recognized.Value; - if (token != null) - { - return Task.FromResult(true); - } - else - { - return Task.FromResult(false); - } - } - - // Helpers - protected Task DigestLuisResult(DialogContext dc) - { - return Task.CompletedTask; - } - - // This method is called by any waterfall step that throws an exception to ensure consistency - protected async Task HandleDialogExceptions(WaterfallStepContext sc, Exception ex) - { - // send trace back to emulator - var trace = new Activity(type: ActivityTypes.Trace, text: $"DialogException: {ex.Message}, StackTrace: {ex.StackTrace}"); - await sc.Context.SendActivityAsync(trace); - - // log exception - TelemetryClient.TrackExceptionEx(ex, sc.Context.Activity, sc.ActiveDialog?.Id); - - // send error message to bot user - await sc.Context.SendActivityAsync(ResponseManager.GetResponse(SharedResponses.ErrorMessage)); - - // clear state - var state = await ConversationStateAccessor.GetAsync(sc.Context); - state.Clear(); - } - - private class DialogIds - { - public const string SkillModeAuth = "SkillAuth"; - } - } -} \ No newline at end of file diff --git a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Shared/Resources/FakeSkillLU.cs b/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Shared/Resources/FakeSkillLU.cs deleted file mode 100644 index 68af3101e8..0000000000 --- a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Shared/Resources/FakeSkillLU.cs +++ /dev/null @@ -1,61 +0,0 @@ -// -// Tool github: https://github.com/microsoft/botbuilder-tools -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// -using Newtonsoft.Json; -using System.Collections.Generic; -namespace Luis -{ - public class FakeSkillLU : Microsoft.Bot.Builder.IRecognizerConvert - { - public string Text; - public string AlteredText; - public enum Intent - { - Sample, - Auth, - None - }; - public Dictionary Intents; - - public class _Entities - { - // Instance - public class _Instance - { - } - [JsonProperty("$instance")] - public _Instance _instance; - } - public _Entities Entities; - - [JsonExtensionData(ReadData = true, WriteData = true)] - public IDictionary Properties { get; set; } - - public void Convert(dynamic result) - { - var app = JsonConvert.DeserializeObject(JsonConvert.SerializeObject(result)); - Text = app.Text; - AlteredText = app.AlteredText; - Intents = app.Intents; - Entities = app.Entities; - Properties = app.Properties; - } - - public (Intent intent, double score) TopIntent() - { - Intent maxIntent = Intent.None; - var max = 0.0; - foreach (var entry in Intents) - { - if (entry.Value.Score > max) - { - maxIntent = entry.Key; - max = entry.Value.Score.Value; - } - } - return (maxIntent, max); - } - } -} \ No newline at end of file diff --git a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Shared/Resources/ResponseIdCollection.t4 b/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Shared/Resources/ResponseIdCollection.t4 deleted file mode 100644 index d6c0d7cc3e..0000000000 --- a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Shared/Resources/ResponseIdCollection.t4 +++ /dev/null @@ -1,31 +0,0 @@ -<#@ assembly name="Newtonsoft.Json.dll" #> -<# - var className = System.IO.Path.GetFileNameWithoutExtension(Host.TemplateFile); - var namespaceName = System.Runtime.Remoting.Messaging.CallContext.LogicalGetData("NamespaceHint"); - string myFile = System.IO.File.ReadAllText(this.Host.ResolvePath(className + ".json")); - var json = Newtonsoft.Json.JsonConvert.DeserializeObject>(myFile); - var responses = string.Empty; - var cards = string.Empty; -#> -// https://docs.microsoft.com/en-us/visualstudio/modeling/t4-include-directive?view=vs-2017 -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using Microsoft.Bot.Builder.Solutions.Responses; - -namespace <#= namespaceName #> -{ - /// - /// Contains bot responses. - /// - public class <#= className #> : IResponseIdCollection - { - // Generated accessors -<# -// This code runs in the text json: -foreach (var propertyName in json) { -#> - public const string <#= propertyName.Key.Substring(0, 1).ToUpperInvariant() + propertyName.Key.Substring(1) #> = "<#= propertyName.Key #>"; -<# } #> - } -} \ No newline at end of file diff --git a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Shared/Resources/SharedResponses.cs b/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Shared/Resources/SharedResponses.cs deleted file mode 100644 index 4aff239014..0000000000 --- a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Shared/Resources/SharedResponses.cs +++ /dev/null @@ -1,22 +0,0 @@ -// https://docs.microsoft.com/en-us/visualstudio/modeling/t4-include-directive?view=vs-2017 -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using Microsoft.Bot.Builder.Solutions.Responses; - -namespace Microsoft.Bot.Builder.Solutions.Tests.Skills.Fakes.FakeSkill.Dialogs.Shared.Resources -{ - /// - /// Contains bot responses. - /// - public class SharedResponses : IResponseIdCollection - { - // Generated accessors - public const string DidntUnderstandMessage = "DidntUnderstandMessage"; - public const string CancellingMessage = "CancellingMessage"; - public const string NoAuth = "NoAuth"; - public const string AuthFailed = "AuthFailed"; - public const string ActionEnded = "ActionEnded"; - public const string ErrorMessage = "ErrorMessage"; - } -} diff --git a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Shared/Resources/SharedResponses.de.json b/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Shared/Resources/SharedResponses.de.json deleted file mode 100644 index 99ff833acf..0000000000 Binary files a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Shared/Resources/SharedResponses.de.json and /dev/null differ diff --git a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Shared/Resources/SharedResponses.es.json b/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Shared/Resources/SharedResponses.es.json deleted file mode 100644 index 0ff0fd7ddf..0000000000 Binary files a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Shared/Resources/SharedResponses.es.json and /dev/null differ diff --git a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Shared/Resources/SharedResponses.fr.json b/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Shared/Resources/SharedResponses.fr.json deleted file mode 100644 index d61e51ca73..0000000000 Binary files a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Shared/Resources/SharedResponses.fr.json and /dev/null differ diff --git a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Shared/Resources/SharedResponses.it.json b/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Shared/Resources/SharedResponses.it.json deleted file mode 100644 index fdf5a5074b..0000000000 Binary files a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Shared/Resources/SharedResponses.it.json and /dev/null differ diff --git a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Shared/Resources/SharedResponses.json b/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Shared/Resources/SharedResponses.json deleted file mode 100644 index f29bd17fe5..0000000000 --- a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Shared/Resources/SharedResponses.json +++ /dev/null @@ -1,148 +0,0 @@ -{ - "DidntUnderstandMessage": { - "replies": [ - { - "text": "Sorry, I didn't understand what you meant.", - "speak": "Sorry, I didn't understand what you meant." - }, - { - "text": "I didn't understand, perhaps try again in a different way.", - "speak": "I didn't understand, perhaps try again in a different way." - }, - { - "text": "Can you try to ask in a different way?", - "speak": "Can you try to ask in a different way?" - }, - { - "text": "I didn't get what you mean, can you try in a different way?", - "speak": "I didn't get what you mean, can you try in a different way?" - }, - { - "text": "Could you elaborate?", - "speak": "Could you elaborate?" - }, - { - "text": "Please say that again in a different way.", - "speak": "Please say that again in a different way." - }, - { - "text": "I didn't quite get that.", - "speak": "I didn't quite get that." - }, - { - "text": "Can you say that in a different way?", - "speak": "Can you say that in a different way?" - }, - { - "text": "Can you try to ask me again? I didn't get what you mean.", - "speak": "Can you try to ask me again? I didn't get what you mean." - } - ], - "inputHint": "acceptingInput" - }, - "CancellingMessage": { - "replies": [ - { - "text": "Sure, we can do this later.", - "speak": "Sure, we can do this later." - }, - { - "text": "Sure, we can start this later.", - "speak": "Sure, we can start this later." - }, - { - "text": "No problem, you can try again at another time.", - "speak": "No problem, you can try again at another time." - }, - { - "text": "Alright, let me know when you need my help.", - "speak": "Alright, let me know when you need my help." - }, - { - "text": "Sure, I'm here if you need me.", - "speak": "Sure, I'm here if you need me." - } - ], - "inputHint": "acceptingInput" - }, - "NoAuth": { - "replies": [ - { - "text": "Please log in before taking further action.", - "speak": "Please log in before taking further action." - }, - { - "text": "Please log in so I can take further action.", - "speak": "Please log in so I can take further action." - }, - { - "text": "Please log in so I can proceed with your request.", - "speak": "Please log in so I can proceed with your request." - }, - { - "text": "Can you log in so I can help you out further?", - "speak": "Can you log in so I can help you out further?" - }, - { - "text": "You need to log in so I can take further action.", - "speak": "You need to log in so I can take further action." - } - ], - "inputHint": "expectingInput" - }, - "AuthFailed": { - "replies": [ - { - "text": "Authentication failed. Please try again", - "speak": "Authentication failed. Please try again." - }, - { - "text": "You failed to log in. Please try again later.", - "speak": "You failed to log in. please try again later." - }, - { - "text": "Your log in failed. Let's try this again.", - "speak": "Your log in failed. Let's try this again." - } - ], - "inputHint": "acceptingInput" - }, - "ActionEnded": { - "replies": [ - { - "text": "Let me know if you need my help with something else.", - "speak": "Let me know if you need my help with something else." - }, - { - "text": "I'm here if you need me.", - "speak": "I'm here if you need me." - } - ], - "inputHint": "acceptingInput" - }, - "ErrorMessage": { - "replies": [ - { - "text": "Sorry, it looks like something went wrong!", - "speak": "Sorry, it looks like something went wrong!" - }, - { - "text": "An error occurred, please try again later.", - "speak": "An error occurred, please try again later." - }, - { - "text": "Something went wrong, sorry!", - "speak": "Something went wrong, sorry!" - }, - { - "text": "It seems like something went wrong. Can you try again later?", - "speak": "It seems like something went wrong. Can you try again later?" - }, - { - "text": "Sorry I can't help right now. Please try again later.", - "speak": "Sorry I can't help right now. Please try again later." - } - ], - "inputHint": "acceptingInput" - } -} diff --git a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Shared/Resources/SharedResponses.tt b/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Shared/Resources/SharedResponses.tt deleted file mode 100644 index d636d96c8b..0000000000 --- a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Shared/Resources/SharedResponses.tt +++ /dev/null @@ -1,3 +0,0 @@ -<#@ template debug="false" hostspecific="true" language="C#" #> -<#@ output extension=".cs" #> -<#@ include file="..\..\Shared\Resources\ResponseIdCollection.t4"#> diff --git a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Shared/Resources/SharedResponses.zh.json b/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Shared/Resources/SharedResponses.zh.json deleted file mode 100644 index 44c91b5ec1..0000000000 --- a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/Dialogs/Shared/Resources/SharedResponses.zh.json +++ /dev/null @@ -1,211 +0,0 @@ -{ - "DidntUnderstandMessage": { - "replies": [ - { - "text": "对不起,没有明白你的意思。", - "speak": "对不起,没有明白你的意思。" - }, - { - "text": "我没有明白你的意思,你能以不同的方式尝试吗?", - "speak": "我没有明白你的意思,你能以不同的方式尝试吗?" - }, - { - "text": "你能以不同的方式说出来吗?", - "speak": "你能以不同的方式说出来吗?" - }, - { - "text": "你能再试一次问我,我没听懂你的意思。", - "speak": "你能再试一次问我,我没听懂你的意思。" - } - ], - "inputHint": "acceptingInput" - }, - "NoAuth": { - "replies": [ - { - "text": "请登录,以便我采取进一步行动。", - "speak": "请登录,以便我采取进一步行动。" - } - ], - "inputHint": "expectingInput" - }, - "AuthFailed": { - "replies": [ - { - "text": "您的登录失败,请稍后再试。", - "speak": "您的登录失败,请稍后再试。" - } - ], - "inputHint": "acceptingInput" - }, - "CancellingMessage": { - "replies": [ - { - "text": "当然,我们可以稍后再做。", - "speak": "当然,我们可以稍后再做。" - } - ], - "inputHint": "acceptingInput" - }, - "ActionEnded": { - "replies": [ - { - "text": "还有什么需要我的帮助吗?", - "speak": "还有什么需要我的帮助吗?" - }, - { - "text": "还有什么我可以帮你的吗?", - "speak": "还有什么我可以帮你的吗?" - }, - { - "text": "还有什么想要采取行动吗?", - "speak": "还有什么想要采取行动吗?" - }, - { - "text": "如果您需要我的帮助,请告诉我。", - "speak": "如果您需要我的帮助,请告诉我。" - }, - { - "text": "如果你需要我的帮助,我就在这里。", - "speak": "如果你需要我的帮助,我就在这里。" - } - ], - "inputHint": "acceptingInput" - }, - "ToDoErrorMessage": { - "replies": [ - { - "text": "对不起,看起来出了问题!", - "speak": "对不起,看起来出了问题!" - }, - { - "text": "发生错误,给我一些时间,稍后再试。", - "speak": "发生错误,给我一些时间,稍后再试。" - }, - { - "text": "出了点问题,对不起!", - "speak": "出了点问题,对不起!" - }, - { - "text": "我相信出了点问题。你稍后可以再试一次吗?", - "speak": "我相信出了点问题。你稍后可以再试一次吗?" - }, - { - "text": "抱歉,我现在找不到你想要的东西。请稍后再试。", - "speak": "抱歉,我现在找不到你想要的东西。请稍后再试。" - } - ], - "inputHint": "acceptingInput" - }, - "ToDoErrorMessage_BotProblem": { - "replies": [ - { - "text": "对不起,出了点问题。开发人员已经收到通知并且在解决这个问题。你很快就又可以正常使用这个功能了。", - "speak": "对不起,出了点问题。开发人员已经收到通知并且在解决这个问题。你很快就又可以正常使用这个功能了。" - } - ], - "inputHint": "acceptingInput" - }, - "SettingUpOneNoteMessage": { - "replies": [ - { - "text": "我注意到你还没有OneNote, 我正在为您创建,包含一个待办事项列表,一个购物列表以及一个杂货列表。", - "speak": "我注意到你还没有OneNote, 我正在为您创建,包含一个待办事项列表,一个购物列表以及一个杂货列表。" - } - ], - "inputHint": "ignoringInput" - }, - "AfterOneNoteSetupMessage": { - "replies": [ - { - "text": "设置完成,我已经给你发送带有OneNote链接的邮件,现在可以记录你的任务了。", - "speak": "设置完成,我已经给你发送带有OneNote链接的邮件,现在可以记录你的任务了。" - } - ], - "inputHint": "ignoringInput" - }, - "SettingUpOutlookMessage": { - "replies": [ - { - "text": "我注意到你还没有Outlook任务簿, 我正在为您创建,包含一个待办事项列表,一个购物列表以及一个杂货列表。", - "speak": "我注意到你还没有Outlook任务簿, 我正在为您创建,包含一个待办事项列表,一个购物列表以及一个杂货列表。" - } - ], - "inputHint": "ignoringInput" - }, - "AfterOutlookSetupMessage": { - "replies": [ - { - "text": "设置完成,我已经给你发送带有Outlook任务簿链接的邮件,现在可以记录你的任务了。", - "speak": "设置完成,我已经给你发送带有Outlook任务簿链接的邮件,现在可以记录你的任务了。" - } - ], - "inputHint": "ignoringInput" - }, - "ShowToDoTasks": { - "replies": [ - { - "text": "您的{listType}列表有{taskCount}个任务:", - "speak": "您的{listType}列表有{taskCount}个任务:" - } - ], - "inputHint": "ignoringInput" - }, - "AskToDoTaskIndex": { - "replies": [ - { - "text": "您想为这个操作选择哪个任务?", - "speak": "您想为这个操作选择哪个任务?" - } - ], - "inputHint": "expectingInput" - }, - "AskToDoContentText": { - "replies": [ - { - "text": "当然。您想加入什么到事项表?", - "speak": "当然。您想加入什么到待办事项表?" - }, - { - "text": "好的,您想加入什么到事项表?", - "speak": "好的,您想加入什么到事项表?" - }, - { - "text": "好,您想加入什么到事项表?", - "speak": "好,您想加入什么到事项表?" - }, - { - "text": "您想加入什么到事项表?", - "speak": "您想加入什么到事项表?" - } - ], - "inputHint": "expectingInput" - }, - "AfterToDoTaskAdded": { - "replies": [ - { - "text": "已经为您加入此任务。", - "speak": "已经为您加入此任务。" - } - ], - "inputHint": "acceptingInput" - }, - "NoTasksInList": { - "replies": [ - { - "text": "您的事项表是空的.", - "speak": "您的事项表是空的." - } - ], - "inputHint": "acceptingInput" - }, - "SwitchListType": { - "replies": [ - { - "text": "这看起来像是{listType}列表的任务。你想要把它加入到{listType}列表吗?", - "speak": "这看起来像是{listType}列表的任务。你想要把它加入到{listType}列表吗?" - } - ], - "inputHint": "expectingInput" - } -} diff --git a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/FakeSkill.cs b/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/FakeSkill.cs deleted file mode 100644 index ee2b3ea20d..0000000000 --- a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/FakeSkill.cs +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System; -using System.Threading; -using System.Threading.Tasks; -using Microsoft.Bot.Builder; -using Microsoft.Bot.Builder.Dialogs; -using Microsoft.Bot.Builder.Solutions.Skills; -using FakeSkill.Dialogs.Main; -using FakeSkill.ServiceClients; -using Microsoft.Bot.Builder.Solutions.Responses; -using Microsoft.Bot.Builder.Solutions.Tests.Skills.Fakes.FakeSkill.Dialogs.Auth.Resources; -using Microsoft.Bot.Builder.Solutions.Tests.Skills.Fakes.FakeSkill.Dialogs.Main.Resources; -using Microsoft.Bot.Builder.Solutions.Tests.Skills.Fakes.FakeSkill.Dialogs.Shared.Resources; -using Microsoft.Bot.Builder.Solutions.Tests.Skills.Fakes.FakeSkill.Dialogs.Sample.Resources; -using Microsoft.Bot.Configuration; -using Microsoft.Bot.Builder.Solutions.TaskExtensions; -using Microsoft.Bot.Builder.Solutions.Proactive; - -namespace FakeSkill -{ - /// - /// Main entry point and orchestration for bot. - /// - public class FakeSkill : IBot - { - private readonly SkillConfigurationBase _services; - private readonly ResponseManager _responseManager; - private readonly ConversationState _conversationState; - private readonly UserState _userState; - private readonly ProactiveState _proactiveState; - private readonly IBotTelemetryClient _telemetryClient; - private readonly IBackgroundTaskQueue _backgroundTaskQueue; - private readonly EndpointService _endpointService; - private IServiceManager _serviceManager; - private DialogSet _dialogs; - private bool _skillMode; - - public FakeSkill(SkillConfigurationBase services, EndpointService endpointService, ConversationState conversationState, UserState userState, ProactiveState proactiveState, IBotTelemetryClient telemetryClient, IBackgroundTaskQueue backgroundTaskQueue, bool skillMode = false, ResponseManager responseManager = null, ServiceManager serviceManager = null) - { - _skillMode = skillMode; - _services = services ?? throw new ArgumentNullException(nameof(services)); - _userState = userState ?? throw new ArgumentNullException(nameof(userState)); - _conversationState = conversationState ?? throw new ArgumentNullException(nameof(conversationState)); - _proactiveState = proactiveState; - _endpointService = endpointService; - _backgroundTaskQueue = backgroundTaskQueue; - _telemetryClient = telemetryClient ?? throw new ArgumentNullException(nameof(telemetryClient)); - _serviceManager = serviceManager ?? new ServiceManager(); - - if(responseManager == null) - { - var locales = new string[] { "en-us", "de-de", "es-es", "fr-fr", "it-it", "zh-cn" }; - responseManager = new ResponseManager( - locales, - new SampleAuthResponses(), - new MainResponses(), - new SharedResponses(), - new SampleResponses()); - } - - _responseManager = responseManager; - _dialogs = new DialogSet(_conversationState.CreateProperty(nameof(DialogState))); - _dialogs.Add(new MainDialog(_services, _responseManager, _conversationState, _userState, _telemetryClient, _serviceManager, _skillMode)); - } - - /// - /// Run every turn of the conversation. Handles orchestration of messages. - /// - /// Bot Turn Context. - /// Task CancellationToken. - /// A representing the asynchronous operation. - public async Task OnTurnAsync(ITurnContext turnContext, CancellationToken cancellationToken) - { - var dc = await _dialogs.CreateContextAsync(turnContext); - - if (dc.ActiveDialog != null) - { - var result = await dc.ContinueDialogAsync(); - } - else - { - await dc.BeginDialogAsync(nameof(MainDialog)); - } - } - } -} \ No newline at end of file diff --git a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/ServiceClients/IServiceManager.cs b/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/ServiceClients/IServiceManager.cs deleted file mode 100644 index 07702d2220..0000000000 --- a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/ServiceClients/IServiceManager.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace FakeSkill.ServiceClients -{ - public interface IServiceManager - { - } -} diff --git a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/ServiceClients/ServiceManager.cs b/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/ServiceClients/ServiceManager.cs deleted file mode 100644 index 45785c8a4b..0000000000 --- a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/ServiceClients/ServiceManager.cs +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -namespace FakeSkill.ServiceClients -{ - public class ServiceManager : IServiceManager - { - } -} \ No newline at end of file diff --git a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/SkillConversationState.cs b/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/SkillConversationState.cs deleted file mode 100644 index 75a7f462e5..0000000000 --- a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/SkillConversationState.cs +++ /dev/null @@ -1,17 +0,0 @@ -using Microsoft.Bot.Builder.Dialogs; - -namespace FakeSkill -{ - public class SkillConversationState : DialogState - { - public SkillConversationState() - { - } - - public string Token { get; internal set; } - - public void Clear() - { - } - } -} \ No newline at end of file diff --git a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/SkillUserState.cs b/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/SkillUserState.cs deleted file mode 100644 index e7ea23581d..0000000000 --- a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Fakes/FakeSkill/SkillUserState.cs +++ /dev/null @@ -1,15 +0,0 @@ -using Microsoft.Bot.Builder.Dialogs; - -namespace FakeSkill -{ - public class SkillUserState : DialogState - { - public SkillUserState() - { - } - - public void Clear() - { - } - } -} \ No newline at end of file diff --git a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/InvokeSkillTests.cs b/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/InvokeSkillTests.cs deleted file mode 100644 index 600b9db0ac..0000000000 --- a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/InvokeSkillTests.cs +++ /dev/null @@ -1,135 +0,0 @@ -using Microsoft.Bot.Schema; -using Microsoft.Bot.Builder.Solutions.Skills; -using Microsoft.Bot.Builder.Solutions.Tests.Skills.Fakes.FakeSkill.Dialogs.Sample.Resources; -using Microsoft.Bot.Builder.Solutions.Tests.Skills.Utterances; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using System; -using System.Collections.Specialized; -using System.Globalization; -using System.Threading.Tasks; - -namespace Microsoft.Bot.Builder.Solutions.Tests.Skills -{ - [TestClass] - public class InvokeSkillTests : SkillTestBase - { - [TestInitialize] - public void InitSkills() - { - // Add Fake Skill registration - const string fakeSkillName = "FakeSkill"; - var fakeSkillDefinition = new SkillDefinition(); - var fakeSkillType = typeof(FakeSkill.FakeSkill); - fakeSkillDefinition.Assembly = fakeSkillType.AssemblyQualifiedName; - fakeSkillDefinition.Id = fakeSkillName; - fakeSkillDefinition.Name = fakeSkillName; - - SkillConfigurations.Add(fakeSkillDefinition.Id, Services); - - // Options are passed to the SkillDialog - SkillDialogOptions = new SkillDialogOptions - { - SkillDefinition = fakeSkillDefinition - }; - - // Add the SkillDialog to the available dialogs passing the initialized FakeSkill - Dialogs.Add(new SkillDialog(fakeSkillDefinition, Services, null, null, TelemetryClient, null)); - } - - /// - /// Test that we can create a skill and complete a end to end flow includign the EndOfConversation event - /// signalling the Skill has completed. - /// - /// - [TestMethod] - public async Task InvokeFakeSkillAndDialog() - { - await GetTestFlow() - .Send(SampleDialogUtterances.Trigger) - .AssertReply(MessagePrompt()) - .Send(SampleDialogUtterances.MessagePromptResponse) - .AssertReply(EchoMessage()) - .AssertReply(this.CheckForEndOfConversationEvent()) - .StartTestAsync(); - } - - /// - /// Replica of above test but testing that localisation is working - /// - /// - [TestMethod] - public async Task InvokeFakeSkillAndDialog_Spanish() - { - var locale = "es-mx"; - - // Set the culture to ES to ensure the reply asserts pull out the spanish variant - CultureInfo.CurrentUICulture = CultureInfo.CurrentCulture = CultureInfo.GetCultureInfo(locale); - - // Use MakeActivity so we can control the locale on the Activity being sent - await GetTestFlow() - .Send(MakeActivity(SampleDialogUtterances.Trigger, locale)) - .AssertReply(MessagePrompt()) - .Send(MakeActivity(SampleDialogUtterances.MessagePromptResponse, locale)) - .AssertReply(EchoMessage()) - .AssertReply(this.CheckForEndOfConversationEvent()) - .StartTestAsync(); - } - - /// - /// Make an activity using the pre-configured Conversation metadata providing a way to control locale - /// - /// - /// - /// - public Activity MakeActivity(string text = null, string locale = null) - { - var activity = new Activity - { - Type = ActivityTypes.Message, - From = ConversationReference.User, - Recipient = ConversationReference.Bot, - Conversation = ConversationReference.Conversation, - ServiceUrl = ConversationReference.ServiceUrl, - Text = text, - Locale = locale ?? null - }; - - return activity; - } - - /// - /// Validate that we have received a EndOfConversation event. The SkillDialog internally consumes this but does - /// send a Trace Event that we check for the presence of. - /// - /// - private Action CheckForEndOfConversationEvent() - { - return activity => - { - var traceActivity = activity as Activity; - Assert.IsNotNull(traceActivity); - - Assert.AreEqual(traceActivity.Type, ActivityTypes.Trace); - Assert.AreEqual(traceActivity.Text, "<--Ending the skill conversation"); - }; - } - - private Action MessagePrompt() - { - return activity => - { - var messageActivity = activity.AsMessageActivity(); - CollectionAssert.Contains(ParseReplies(SampleResponses.MessagePrompt, new StringDictionary()), messageActivity.Text); - }; - } - - private Action EchoMessage() - { - return activity => - { - var messageActivity = activity.AsMessageActivity(); - CollectionAssert.Contains(ParseReplies(SampleResponses.MessageResponse, new[] { SampleDialogUtterances.MessagePromptResponse }), messageActivity.Text); - }; - } - } -} \ No newline at end of file diff --git a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/LuisTestUtils/FakeSkillTestUtil.cs b/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/LuisTestUtils/FakeSkillTestUtil.cs deleted file mode 100644 index 8bf009194c..0000000000 --- a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/LuisTestUtils/FakeSkillTestUtil.cs +++ /dev/null @@ -1,42 +0,0 @@ -using Luis; -using Microsoft.Bot.Builder; -using Microsoft.Bot.Builder.Solutions.Testing.Mocks; -using Microsoft.Bot.Builder.Solutions.Tests.Skills.Utterances; -using System.Collections.Generic; - -namespace Microsoft.Bot.Builder.Solutions.Tests.Skills.LuisTestUtils -{ - public class FakeSkillTestUtil - { - private static Dictionary _utterances = new Dictionary - { - { SampleDialogUtterances.Trigger, CreateIntent(SampleDialogUtterances.Trigger, FakeSkillLU.Intent.Sample) }, - { SampleDialogUtterances.Auth, CreateIntent(SampleDialogUtterances.Auth, FakeSkillLU.Intent.Auth) } - }; - - public static MockLuisRecognizer CreateRecognizer() - { - var recognizer = new MockLuisRecognizer(defaultIntent: CreateIntent(string.Empty, FakeSkillLU.Intent.None)); - recognizer.RegisterUtterances(_utterances); - return recognizer; - } - - public static FakeSkillLU CreateIntent(string userInput, FakeSkillLU.Intent intent) - { - var result = new FakeSkillLU - { - Text = userInput, - Intents = new Dictionary() - }; - - result.Intents.Add(intent, new IntentScore() { Score = 0.9 }); - - result.Entities = new FakeSkillLU._Entities - { - _instance = new FakeSkillLU._Entities._Instance() - }; - - return result; - } - } -} diff --git a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/LuisTestUtils/GeneralTestUtil.cs b/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/LuisTestUtils/GeneralTestUtil.cs deleted file mode 100644 index 30aaab73a1..0000000000 --- a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/LuisTestUtils/GeneralTestUtil.cs +++ /dev/null @@ -1,47 +0,0 @@ -using Luis; -using Microsoft.Bot.Builder; -using Microsoft.Bot.Builder.Solutions.Testing.Mocks; -using Microsoft.Bot.Builder.Solutions.Tests.Skills.Utterances; -using System.Collections.Generic; - -namespace Microsoft.Bot.Builder.Solutions.Tests.Skills.LuisTestUtils -{ - public class GeneralTestUtil - { - private static Dictionary _utterances = new Dictionary - { - { GeneralUtterances.Cancel, CreateIntent(GeneralUtterances.Cancel, General.Intent.Cancel) }, - { GeneralUtterances.Escalate, CreateIntent(GeneralUtterances.Escalate, General.Intent.Escalate) }, - { GeneralUtterances.Help, CreateIntent(GeneralUtterances.Help, General.Intent.Help) }, - { GeneralUtterances.Logout, CreateIntent(GeneralUtterances.Logout, General.Intent.Logout) }, - { GeneralUtterances.Next, CreateIntent(GeneralUtterances.Next, General.Intent.ShowNext) }, - { GeneralUtterances.Previous, CreateIntent(GeneralUtterances.Previous, General.Intent.ShowPrevious) }, - { GeneralUtterances.Restart, CreateIntent(GeneralUtterances.Restart, General.Intent.GoBack) }, - }; - - public static MockLuisRecognizer CreateRecognizer() - { - var recognizer = new MockLuisRecognizer(defaultIntent: CreateIntent(string.Empty, General.Intent.None)); - recognizer.RegisterUtterances(_utterances); - return recognizer; - } - - public static General CreateIntent(string userInput, General.Intent intent) - { - var result = new General - { - Text = userInput, - Intents = new Dictionary() - }; - - result.Intents.Add(intent, new IntentScore() { Score = 0.9 }); - - result.Entities = new General._Entities - { - _instance = new General._Entities._Instance() - }; - - return result; - } - } -} diff --git a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/MisconfiguredSkillTest.cs b/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/MisconfiguredSkillTest.cs deleted file mode 100644 index 44e15855f6..0000000000 --- a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/MisconfiguredSkillTest.cs +++ /dev/null @@ -1,47 +0,0 @@ -using Microsoft.Bot.Builder.Solutions.Skills; -using Microsoft.Bot.Builder.Solutions.Tests.Skills.Utterances; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using System.Threading.Tasks; - -namespace Microsoft.Bot.Builder.Solutions.Tests.Skills -{ - [TestClass] - public class MisconfiguredSkillTest : SkillTestBase - { - [TestInitialize] - public void InitSkills() - { - // Add Fake Skill registration - const string fakeSkillName = "FakeSkill"; - var fakeSkillDefinition = new SkillDefinition(); - var fakeSkillType = typeof(FakeSkill.FakeSkill); - fakeSkillDefinition.Id = fakeSkillName; - fakeSkillDefinition.Name = fakeSkillName; - - // Set Assembly name to invalid value - fakeSkillDefinition.Assembly = "FakeSkill.FakeSkil, Microsoft.Bot.Builder.Solutions.Tests, Version = 1.0.0.0, Culture = neutral, PublicKeyToken = null"; - - SkillConfigurations.Add(fakeSkillDefinition.Id, Services); - - // Options are passed to the SkillDialog - SkillDialogOptions = new SkillDialogOptions(); - SkillDialogOptions.SkillDefinition = fakeSkillDefinition; - - // Add the SkillDialog to the available dialogs passing the initialized FakeSkill - Dialogs.Add(new SkillDialog(fakeSkillDefinition, Services, null, null, TelemetryClient, null)); - } - - /// - /// Validate that Skill instantiation errors are surfaced as exceptions - /// - /// - [TestMethod] - [ExpectedException(typeof(System.InvalidOperationException), "Skill (FakeSkill) could not be created.")] - public async Task MisconfiguredSkill() - { - await GetTestFlow() - .Send(SampleDialogUtterances.Trigger) - .StartTestAsync(); - } - } -} \ No newline at end of file diff --git a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/SkillTestBase.cs b/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/SkillTestBase.cs deleted file mode 100644 index d6ca8b45df..0000000000 --- a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/SkillTestBase.cs +++ /dev/null @@ -1,153 +0,0 @@ -using System.Collections.Generic; -using Autofac; -using Microsoft.Bot.Builder; -using Microsoft.Bot.Builder.Adapters; -using Microsoft.Bot.Builder.Dialogs; -using Microsoft.Bot.Configuration; -using Microsoft.Bot.Schema; -using Microsoft.Bot.Builder.Solutions.Proactive; -using Microsoft.Bot.Builder.Solutions.Responses; -using Microsoft.Bot.Builder.Solutions.Skills; -using Microsoft.Bot.Builder.Solutions.TaskExtensions; -using Microsoft.Bot.Builder.Solutions.Telemetry; -using Microsoft.Bot.Builder.Solutions.Testing; -using Microsoft.Bot.Builder.Solutions.Testing.Mocks; -using Microsoft.Bot.Builder.Solutions.Tests.Skills.Fakes.FakeSkill.Dialogs.Auth.Resources; -using Microsoft.Bot.Builder.Solutions.Tests.Skills.Fakes.FakeSkill.Dialogs.Main.Resources; -using Microsoft.Bot.Builder.Solutions.Tests.Skills.Fakes.FakeSkill.Dialogs.Sample.Resources; -using Microsoft.Bot.Builder.Solutions.Tests.Skills.Fakes.FakeSkill.Dialogs.Shared.Resources; -using Microsoft.Bot.Builder.Solutions.Tests.Skills.LuisTestUtils; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace Microsoft.Bot.Builder.Solutions.Tests.Skills -{ - [TestClass] - public class SkillTestBase : BotTestBase - { - public DialogSet Dialogs { get; set; } - - public UserState UserState { get; set; } - - public ConversationState ConversationState { get; set; } - - public ProactiveState ProactiveState { get; set; } - - public IStatePropertyAccessor DialogState { get; set; } - - public IBotTelemetryClient TelemetryClient { get; set; } - - public IBackgroundTaskQueue BackgroundTaskQueue { get; set; } - - public EndpointService EndpointService { get; set; } - - public SkillConfigurationBase Services { get; set; } - - public Dictionary SkillConfigurations { get; set; } - - public SkillDialogOptions SkillDialogOptions { get; set; } - - public ConversationReference ConversationReference { get; set; } - - [TestInitialize] - public new void Initialize() - { - var builder = new ContainerBuilder(); - - ConversationState = new ConversationState(new MemoryStorage()); - DialogState = ConversationState.CreateProperty(nameof(DialogState)); - UserState = new UserState(new MemoryStorage()); - ProactiveState = new ProactiveState(new MemoryStorage()); - TelemetryClient = new NullBotTelemetryClient(); - BackgroundTaskQueue = new BackgroundTaskQueue(); - EndpointService = new EndpointService(); - SkillConfigurations = new Dictionary(); - - // Add the LUIS model fakes used by the Skill - Services = new MockSkillConfiguration(); - Services.LocaleConfigurations.Add("en", new LocaleConfiguration() - { - Locale = "en-us", - LuisServices = new Dictionary - { - { "general", GeneralTestUtil.CreateRecognizer() }, - { "FakeSkill", FakeSkillTestUtil.CreateRecognizer() } - } - }); - - Services.LocaleConfigurations.Add("es", new LocaleConfiguration() - { - Locale = "es-mx", - LuisServices = new Dictionary - { - { "general", GeneralTestUtil.CreateRecognizer() }, - { "FakeSkill", FakeSkillTestUtil.CreateRecognizer() } - } - }); - - // Dummy Authentication connection for Auth testing - Services.AuthenticationConnections = new Dictionary - { - { "DummyAuth", "DummyAuthConnection" } - }; - - builder.RegisterInstance(new BotStateSet(UserState, ConversationState)); - Container = builder.Build(); - - Dialogs = new DialogSet(DialogState); - - var locales = new string[] { "en-us", "de-de", "es-es", "fr-fr", "it-it", "zh-cn" }; - ResponseManager = new ResponseManager( - locales, - new SampleAuthResponses(), - new MainResponses(), - new SharedResponses(), - new SampleResponses()); - - // Manually mange the conversation metadata when we need finer grained control - ConversationReference = new ConversationReference - { - ChannelId = "test", - ServiceUrl = "https://test.com", - }; - - ConversationReference.User = new ChannelAccount("user1", "User1"); - ConversationReference.Bot = new ChannelAccount("bot", "Bot"); - ConversationReference.Conversation = new ConversationAccount(false, "convo1", "Conversation1"); - } - - /// - /// Create a TestFlow which spins up a CustomSkillDialog ready for the tests to execute against - /// - /// - /// - /// - public TestFlow GetTestFlow(string locale = null, SkillDialogOptions overrideSkillDialogOptions = null) - { - var adapter = new TestAdapter(sendTraceActivity: true) - .Use(new AutoSaveStateMiddleware(ConversationState)); - - var testFlow = new TestFlow(adapter, async (context, cancellationToken) => - { - var dc = await Dialogs.CreateContextAsync(context); - - if (dc.ActiveDialog != null) - { - var result = await dc.ContinueDialogAsync(); - } - else - { - var options = overrideSkillDialogOptions ?? SkillDialogOptions; - await dc.BeginDialogAsync(options.SkillDefinition.Id, options); - var result = await dc.ContinueDialogAsync(); - } - }); - - return testFlow; - } - - public override IBot BuildBot() - { - return new FakeSkill.FakeSkill(Services, EndpointService, ConversationState, UserState, ProactiveState, TelemetryClient, BackgroundTaskQueue, true, ResponseManager, null); - } - } -} \ No newline at end of file diff --git a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Utterances/GeneralUtterances.Designer.cs b/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Utterances/GeneralUtterances.Designer.cs deleted file mode 100644 index c0fcfad371..0000000000 --- a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Utterances/GeneralUtterances.Designer.cs +++ /dev/null @@ -1,144 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Microsoft.Bot.Builder.Solutions.Tests.Skills.Utterances { - using System; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - public class GeneralUtterances { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal GeneralUtterances() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - public static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.Bot.Builder.Solutions.Tests.Skills.Utterances.GeneralUtterances", typeof(GeneralUtterances).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - public static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Looks up a localized string similar to cancel. - /// - public static string Cancel { - get { - return ResourceManager.GetString("Cancel", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to can i talk to a person. - /// - public static string Escalate { - get { - return ResourceManager.GetString("Escalate", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to goodbye. - /// - public static string Goodbye { - get { - return ResourceManager.GetString("Goodbye", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Hi. - /// - public static string Greeting { - get { - return ResourceManager.GetString("Greeting", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to help. - /// - public static string Help { - get { - return ResourceManager.GetString("Help", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to log out. - /// - public static string Logout { - get { - return ResourceManager.GetString("Logout", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to next please. - /// - public static string Next { - get { - return ResourceManager.GetString("Next", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to last one. - /// - public static string Previous { - get { - return ResourceManager.GetString("Previous", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to start over. - /// - public static string Restart { - get { - return ResourceManager.GetString("Restart", resourceCulture); - } - } - } -} diff --git a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Utterances/GeneralUtterances.resx b/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Utterances/GeneralUtterances.resx deleted file mode 100644 index b851d23083..0000000000 --- a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Utterances/GeneralUtterances.resx +++ /dev/null @@ -1,147 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - cancel - - - can i talk to a person - - - goodbye - - - Hi - - - help - - - log out - - - next please - - - last one - - - start over - - \ No newline at end of file diff --git a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Utterances/SampleDialogUtterances.Designer.cs b/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Utterances/SampleDialogUtterances.Designer.cs deleted file mode 100644 index 3b026c25cc..0000000000 --- a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Utterances/SampleDialogUtterances.Designer.cs +++ /dev/null @@ -1,90 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Microsoft.Bot.Builder.Solutions.Tests.Skills.Utterances { - using System; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - public class SampleDialogUtterances { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal SampleDialogUtterances() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - public static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.Bot.Builder.Solutions.Tests.Skills.Utterances.SampleDialogUtterances", typeof(SampleDialogUtterances).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - public static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Looks up a localized string similar to auth. - /// - public static string Auth { - get { - return ResourceManager.GetString("Auth", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to this is a message. - /// - public static string MessagePromptResponse { - get { - return ResourceManager.GetString("MessagePromptResponse", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to test. - /// - public static string Trigger { - get { - return ResourceManager.GetString("Trigger", resourceCulture); - } - } - } -} diff --git a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Utterances/SampleDialogUtterances.resx b/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Utterances/SampleDialogUtterances.resx deleted file mode 100644 index eaf7247dd9..0000000000 --- a/lib/csharp/microsoft.bot.builder.solutions/microsoft.bot.builder.solutions.tests/Skills/Utterances/SampleDialogUtterances.resx +++ /dev/null @@ -1,129 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - auth - - - this is a message - - - test - - \ No newline at end of file diff --git a/skills/src/csharp/automotiveskill/automotiveskill/Adapters/AutomotiveSkillAdapter.cs b/skills/src/csharp/automotiveskill/automotiveskill/Adapters/AutomotiveSkillAdapter.cs index 2d06f8592b..50c60707e4 100644 --- a/skills/src/csharp/automotiveskill/automotiveskill/Adapters/AutomotiveSkillAdapter.cs +++ b/skills/src/csharp/automotiveskill/automotiveskill/Adapters/AutomotiveSkillAdapter.cs @@ -37,6 +37,7 @@ public AutomotiveSkillAdapter( Use(new SetLocaleMiddleware(settings.DefaultLocale ?? "en-us")); Use(new EventDebuggerMiddleware()); Use(new AutoSaveStateMiddleware(userState, conversationState)); + Use(new SkillMiddleware(userState)); } } } \ No newline at end of file diff --git a/skills/src/csharp/calendarskill/calendarskill/Adapters/CalendarSkillAdapter.cs b/skills/src/csharp/calendarskill/calendarskill/Adapters/CalendarSkillAdapter.cs index c4a49663ba..2e5ebda2be 100644 --- a/skills/src/csharp/calendarskill/calendarskill/Adapters/CalendarSkillAdapter.cs +++ b/skills/src/csharp/calendarskill/calendarskill/Adapters/CalendarSkillAdapter.cs @@ -19,7 +19,8 @@ public CalendarSkillAdapter( ICredentialProvider credentialProvider, BotStateSet botStateSet, ResponseManager responseManager, - IBotTelemetryClient telemetryClient) + IBotTelemetryClient telemetryClient, + UserState userState) : base(credentialProvider) { OnTurnError = async (context, exception) => @@ -36,6 +37,7 @@ public CalendarSkillAdapter( Use(new SetLocaleMiddleware(settings.DefaultLocale ?? "en-us")); Use(new EventDebuggerMiddleware()); Use(new AutoSaveStateMiddleware(botStateSet)); + Use(new SkillMiddleware(userState)); } } } \ No newline at end of file diff --git a/skills/src/csharp/emailskill/emailskill/Adapters/EmailSkillAdapter.cs b/skills/src/csharp/emailskill/emailskill/Adapters/EmailSkillAdapter.cs index cd0b6ff814..dd21804b6f 100644 --- a/skills/src/csharp/emailskill/emailskill/Adapters/EmailSkillAdapter.cs +++ b/skills/src/csharp/emailskill/emailskill/Adapters/EmailSkillAdapter.cs @@ -19,7 +19,8 @@ public EmailSkillAdapter( ICredentialProvider credentialProvider, BotStateSet botStateSet, ResponseManager responseManager, - IBotTelemetryClient telemetryClient) + IBotTelemetryClient telemetryClient, + UserState userState) : base(credentialProvider) { OnTurnError = async (context, exception) => @@ -36,6 +37,7 @@ public EmailSkillAdapter( Use(new SetLocaleMiddleware(settings.DefaultLocale ?? "en-us")); Use(new EventDebuggerMiddleware()); Use(new AutoSaveStateMiddleware(botStateSet)); + Use(new SkillMiddleware(userState)); } } } \ No newline at end of file diff --git a/skills/src/csharp/experimental/newsskill/Adapters/NewsSkillAdapter.cs b/skills/src/csharp/experimental/newsskill/Adapters/NewsSkillAdapter.cs index f7ce5a6150..cad89b4684 100644 --- a/skills/src/csharp/experimental/newsskill/Adapters/NewsSkillAdapter.cs +++ b/skills/src/csharp/experimental/newsskill/Adapters/NewsSkillAdapter.cs @@ -35,6 +35,7 @@ public NewsSkillAdapter( Use(new SetLocaleMiddleware(settings.DefaultLocale ?? "en-us")); Use(new EventDebuggerMiddleware()); Use(new AutoSaveStateMiddleware(userState, conversationState)); + Use(new SkillMiddleware(userState)); } } } \ No newline at end of file diff --git a/skills/src/csharp/experimental/restaurantbooking/Adapters/RestaurantSkillAdapter.cs b/skills/src/csharp/experimental/restaurantbooking/Adapters/RestaurantSkillAdapter.cs index 06d480e527..fafe132e30 100644 --- a/skills/src/csharp/experimental/restaurantbooking/Adapters/RestaurantSkillAdapter.cs +++ b/skills/src/csharp/experimental/restaurantbooking/Adapters/RestaurantSkillAdapter.cs @@ -37,6 +37,7 @@ public RestaurantSkillAdapter( Use(new SetLocaleMiddleware(settings.DefaultLocale ?? "en-us")); Use(new EventDebuggerMiddleware()); Use(new AutoSaveStateMiddleware(userState, conversationState)); + Use(new SkillMiddleware(userState)); } } } \ No newline at end of file diff --git a/skills/src/csharp/experimental/restaurantbooking/Dialogs/BookingDialog.cs b/skills/src/csharp/experimental/restaurantbooking/Dialogs/BookingDialog.cs index 8ad57e631f..06dbfa3870 100644 --- a/skills/src/csharp/experimental/restaurantbooking/Dialogs/BookingDialog.cs +++ b/skills/src/csharp/experimental/restaurantbooking/Dialogs/BookingDialog.cs @@ -91,7 +91,7 @@ public BookingDialog( // This would be passed from the Virtual Assistant moving forward var tokens = new StringDictionary { - { "UserName", "Jane" } + { "UserName", state.Name ?? "Unknown" } }; // Start the flow diff --git a/skills/src/csharp/experimental/restaurantbooking/Dialogs/MainDialog.cs b/skills/src/csharp/experimental/restaurantbooking/Dialogs/MainDialog.cs index 1a77537c07..20ed0cc5b2 100644 --- a/skills/src/csharp/experimental/restaurantbooking/Dialogs/MainDialog.cs +++ b/skills/src/csharp/experimental/restaurantbooking/Dialogs/MainDialog.cs @@ -10,6 +10,7 @@ using Microsoft.AspNetCore.Http; using Microsoft.Bot.Builder; using Microsoft.Bot.Builder.Dialogs; +using Microsoft.Bot.Builder.Skills; using Microsoft.Bot.Builder.Solutions.Dialogs; using Microsoft.Bot.Builder.Solutions.Responses; using Microsoft.Bot.Schema; @@ -118,6 +119,22 @@ public MainDialog( } } + private async Task PopulateStateFromSkillContext(ITurnContext context) + { + // If we have a SkillContext object populated from the SkillMiddleware we can retrieve requests slot (parameter) data + // and make available in local state as appropriate. + var accessor = _userState.CreateProperty(nameof(SkillContext)); + var skillContext = await accessor.GetAsync(context, () => new SkillContext()); + if (skillContext != null) + { + if (skillContext.ContainsKey("Name")) + { + var state = await _conversationStateAccessor.GetAsync(context, () => new RestaurantBookingState()); + state.Name = skillContext["Name"] as string; + } + } + } + protected override async Task CompleteAsync(DialogContext dc, DialogTurnResult result = null, CancellationToken cancellationToken = default(CancellationToken)) { var response = dc.Context.Activity.CreateReply(); diff --git a/skills/src/csharp/experimental/restaurantbooking/Models/RestaurantBookingState.cs b/skills/src/csharp/experimental/restaurantbooking/Models/RestaurantBookingState.cs index 66e9d9ceed..6602839bdc 100644 --- a/skills/src/csharp/experimental/restaurantbooking/Models/RestaurantBookingState.cs +++ b/skills/src/csharp/experimental/restaurantbooking/Models/RestaurantBookingState.cs @@ -11,6 +11,8 @@ public RestaurantBookingState() AmbiguousTimexExpressions = new Dictionary(); } + public string Name { get; set; } + public Luis.ReservationLuis LuisResult { get; set; } public ReservationBooking Booking { get; set; } @@ -23,6 +25,7 @@ public RestaurantBookingState() public void Clear() { + Name = null; LuisResult = null; Booking = null; Cuisine = null; diff --git a/skills/src/csharp/pointofinterestskill/pointofinterestskill/Adapters/POISkillAdapter.cs b/skills/src/csharp/pointofinterestskill/pointofinterestskill/Adapters/POISkillAdapter.cs index 937f13108a..3fabfa1b64 100644 --- a/skills/src/csharp/pointofinterestskill/pointofinterestskill/Adapters/POISkillAdapter.cs +++ b/skills/src/csharp/pointofinterestskill/pointofinterestskill/Adapters/POISkillAdapter.cs @@ -19,7 +19,8 @@ public POISkillAdapter( ICredentialProvider credentialProvider, BotStateSet botStateSet, ResponseManager responseManager, - IBotTelemetryClient telemetryClient) + IBotTelemetryClient telemetryClient, + UserState userState) : base(credentialProvider) { OnTurnError = async (context, exception) => @@ -36,6 +37,7 @@ public POISkillAdapter( Use(new SetLocaleMiddleware(settings.DefaultLocale ?? "en-us")); Use(new EventDebuggerMiddleware()); Use(new AutoSaveStateMiddleware(botStateSet)); + Use(new SkillMiddleware(userState)); } } } \ No newline at end of file diff --git a/skills/src/csharp/pointofinterestskill/pointofinterestskill/Dialogs/MainDialog.cs b/skills/src/csharp/pointofinterestskill/pointofinterestskill/Dialogs/MainDialog.cs index 6ad57dbd8a..5aa6b8af6d 100644 --- a/skills/src/csharp/pointofinterestskill/pointofinterestskill/Dialogs/MainDialog.cs +++ b/skills/src/csharp/pointofinterestskill/pointofinterestskill/Dialogs/MainDialog.cs @@ -11,6 +11,7 @@ using Microsoft.AspNetCore.Http; using Microsoft.Bot.Builder; using Microsoft.Bot.Builder.Dialogs; +using Microsoft.Bot.Builder.Skills; using Microsoft.Bot.Builder.Solutions.Dialogs; using Microsoft.Bot.Builder.Solutions.Responses; using Microsoft.Bot.Schema; @@ -63,7 +64,7 @@ public MainDialog( protected override async Task OnStartAsync(DialogContext dc, CancellationToken cancellationToken = default(CancellationToken)) { // send a greeting if we're in local mode - await dc.Context.SendActivityAsync(_responseManager.GetResponse(POIMainResponses.PointOfInterestWelcomeMessage)); + await dc.Context.SendActivityAsync(_responseManager.GetResponse(POIMainResponses.PointOfInterestWelcomeMessage)); } protected override async Task RouteAsync(DialogContext dc, CancellationToken cancellationToken = default(CancellationToken)) @@ -72,6 +73,8 @@ public MainDialog( var locale = CultureInfo.CurrentUICulture.TwoLetterISOLanguageName; var localeConfig = _services.CognitiveModelSets[locale]; + await PopulateStateFromSkillContext(dc.Context); + // If dispatch result is general luis model localeConfig.LuisServices.TryGetValue("pointofinterest", out var luisService); @@ -136,6 +139,36 @@ public MainDialog( } } + private async Task PopulateStateFromSkillContext(ITurnContext context) + { + // If we have a SkillContext object populated from the SkillMiddleware we can retrieve requests slot (parameter) data + // and make available in local state as appropriate. + var accessor = _userState.CreateProperty(nameof(SkillContext)); + var skillContext = await accessor.GetAsync(context, () => new SkillContext()); + if (skillContext != null) + { + if (skillContext.ContainsKey("Location")) + { + var location = skillContext["Location"]; + var coords = ((string)location).Split(','); + if (coords.Length == 2) + { + if (double.TryParse(coords[0], out var lat) && double.TryParse(coords[1], out var lng)) + { + var coordinates = new LatLng + { + Latitude = lat, + Longitude = lng, + }; + + var state = await _stateAccessor.GetAsync(context, () => new PointOfInterestSkillState()); + state.CurrentCoordinates = coordinates; + } + } + } + } + } + protected override async Task CompleteAsync(DialogContext dc, DialogTurnResult result = null, CancellationToken cancellationToken = default(CancellationToken)) { var response = dc.Context.Activity.CreateReply(); @@ -153,31 +186,6 @@ public MainDialog( switch (dc.Context.Activity.Name) { - case Events.SkillBeginEvent: - { - if (dc.Context.Activity.Value is Dictionary userData) - { - if (userData.TryGetValue("IPA.Location", out var location)) - { - var coords = ((string)location).Split(','); - if (coords.Length == 2) - { - if (double.TryParse(coords[0], out var lat) && double.TryParse(coords[1], out var lng)) - { - var coordinates = new LatLng - { - Latitude = lat, - Longitude = lng, - }; - state.CurrentCoordinates = coordinates; - } - } - } - } - - break; - } - case Events.Location: { // Test trigger with diff --git a/skills/src/csharp/todoskill/todoskill/Adapters/ToDoSkillAdapter.cs b/skills/src/csharp/todoskill/todoskill/Adapters/ToDoSkillAdapter.cs index a54658f774..0ed4d187da 100644 --- a/skills/src/csharp/todoskill/todoskill/Adapters/ToDoSkillAdapter.cs +++ b/skills/src/csharp/todoskill/todoskill/Adapters/ToDoSkillAdapter.cs @@ -37,6 +37,7 @@ public ToDoSkillAdapter( Use(new SetLocaleMiddleware(settings.DefaultLocale ?? "en-us")); Use(new EventDebuggerMiddleware()); Use(new AutoSaveStateMiddleware(userState, conversationState)); + Use(new SkillMiddleware(userState)); } } }