Skip to content
This repository has been archived by the owner on Jun 30, 2022. It is now read-only.

Commit

Permalink
Skill project updates (#2371)
Browse files Browse the repository at this point in the history
* fixed stylecop warning

* added tests for single-turn completion

* stylecop fix

* completeasync fix for experimental skills

* added nuget source to props file

* removed nuget sources from csproj files

* [VA] moved myget package source to props file

* [Skill] single turn dialog changes

* [Skill] moved myget package source to props file
  • Loading branch information
lauren-mills committed Sep 16, 2019
1 parent 1d2cefa commit d3756df
Show file tree
Hide file tree
Showing 45 changed files with 333 additions and 257 deletions.
6 changes: 6 additions & 0 deletions skills/src/csharp/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
<PropertyGroup>
<CodeAnalysisRuleSet>$(SolutionDir)..\..\..\VirtualAssistant.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>

<PropertyGroup>
<RestoreAdditionalProjectSources>
https://botbuilder.myget.org/F/aitemplates/api/v3/index.json;
</RestoreAdditionalProjectSources>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="StyleCop.Analyzers" Version="1.1.0-beta008" PrivateAssets="all" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
using Microsoft.Bot.Builder;
using Microsoft.Bot.Builder.Dialogs;
using Microsoft.Bot.Builder.Dialogs.Choices;
using Microsoft.Bot.Builder.Solutions;
using Microsoft.Bot.Builder.Skills.Models;
using Microsoft.Bot.Builder.Solutions;
using Microsoft.Bot.Builder.Solutions.Dialogs;
using Microsoft.Bot.Builder.Solutions.Responses;
using Microsoft.Bot.Connector;
Expand Down Expand Up @@ -73,7 +73,6 @@ public MainDialog(
}
else
{
var turnResult = EndOfTurn;
var result = await luisService.RecognizeAsync<Luis.SettingsLuis>(dc.Context, CancellationToken.None);
var intent = result?.TopIntent().intent;

Expand All @@ -87,31 +86,22 @@ public MainDialog(
case SettingsLuis.Intent.VEHICLE_SETTINGS_DECLARATIVE:
case SettingsLuis.Intent.VEHICLE_SETTINGS_CHECK:
{
turnResult = await dc.BeginDialogAsync(nameof(VehicleSettingsDialog));
await dc.BeginDialogAsync(nameof(VehicleSettingsDialog));
break;
}

case SettingsLuis.Intent.None:
{
await dc.Context.SendActivityAsync(_responseManager.GetResponse(AutomotiveSkillSharedResponses.DidntUnderstandMessage));
turnResult = new DialogTurnResult(DialogTurnStatus.Complete);

break;
}

default:
{
await dc.Context.SendActivityAsync(_responseManager.GetResponse(AutomotiveSkillMainResponses.FeatureNotAvailable));
turnResult = new DialogTurnResult(DialogTurnStatus.Complete);

break;
}
}

if (turnResult != EndOfTurn)
{
await CompleteAsync(dc);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System.Collections.Specialized;
using System.Threading.Tasks;
using AutomotiveSkill.Responses.Shared;
using Microsoft.Bot.Schema;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace AutomotiveSkillTest.Flow
{
[TestClass]
public class GeneralSkillFlowTests : AutomotiveSkillTestBase
{
[TestMethod]
public async Task Test_SingleTurnCompletion()
{
await this.GetTestFlow()
.Send("what's the weather?")
.AssertReplyOneOf(this.ConfusedResponse())
.AssertReply((activity) => { Assert.AreEqual(ActivityTypes.Handoff, activity.Type); })
.StartTestAsync();
}

private string[] ConfusedResponse()
{
return this.ParseReplies(AutomotiveSkillSharedResponses.DidntUnderstandMessage, new StringDictionary());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
<TargetFramework>netcoreapp2.2</TargetFramework>
<UserSecretsId>2bdd896c-393e-47c4-b6b9-a47238550b83</UserSecretsId>
<NoWarn>NU1701</NoWarn>
<RestoreAdditionalProjectSources>
https://botbuilder.myget.org/F/aitemplates/api/v3/index.json;
</RestoreAdditionalProjectSources>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ public MainDialog(
}
else
{
var turnResult = EndOfTurn;
var intent = state.LuisResult?.TopIntent().intent;
var generalTopIntent = state.GeneralLuisResult?.TopIntent().intent;

Expand All @@ -114,31 +113,31 @@ public MainDialog(
case CalendarLuis.Intent.FindMeetingRoom:
case CalendarLuis.Intent.CreateCalendarEntry:
{
turnResult = await dc.BeginDialogAsync(nameof(CreateEventDialog), options);
await dc.BeginDialogAsync(nameof(CreateEventDialog), options);
break;
}

case CalendarLuis.Intent.AcceptEventEntry:
{
turnResult = await dc.BeginDialogAsync(nameof(ChangeEventStatusDialog), new ChangeEventStatusDialogOptions(options, EventStatus.Accepted));
await dc.BeginDialogAsync(nameof(ChangeEventStatusDialog), new ChangeEventStatusDialogOptions(options, EventStatus.Accepted));
break;
}

case CalendarLuis.Intent.DeleteCalendarEntry:
{
turnResult = await dc.BeginDialogAsync(nameof(ChangeEventStatusDialog), new ChangeEventStatusDialogOptions(options, EventStatus.Cancelled));
await dc.BeginDialogAsync(nameof(ChangeEventStatusDialog), new ChangeEventStatusDialogOptions(options, EventStatus.Cancelled));
break;
}

case CalendarLuis.Intent.ChangeCalendarEntry:
{
turnResult = await dc.BeginDialogAsync(nameof(UpdateEventDialog), options);
await dc.BeginDialogAsync(nameof(UpdateEventDialog), options);
break;
}

case CalendarLuis.Intent.ConnectToMeeting:
{
turnResult = await dc.BeginDialogAsync(nameof(JoinEventDialog), options);
await dc.BeginDialogAsync(nameof(JoinEventDialog), options);
break;
}

Expand All @@ -149,33 +148,32 @@ public MainDialog(
case CalendarLuis.Intent.FindCalendarWho:
case CalendarLuis.Intent.FindDuration:
{
turnResult = await dc.BeginDialogAsync(nameof(ShowEventsDialog), new ShowMeetingsDialogOptions(ShowMeetingsDialogOptions.ShowMeetingReason.FirstShowOverview, options));
await dc.BeginDialogAsync(nameof(ShowEventsDialog), new ShowMeetingsDialogOptions(ShowMeetingsDialogOptions.ShowMeetingReason.FirstShowOverview, options));
break;
}

case CalendarLuis.Intent.TimeRemaining:
{
turnResult = await dc.BeginDialogAsync(nameof(TimeRemainingDialog));
await dc.BeginDialogAsync(nameof(TimeRemainingDialog));
break;
}

case CalendarLuis.Intent.ShowNextCalendar:
case CalendarLuis.Intent.ShowPreviousCalendar:
{
turnResult = await dc.BeginDialogAsync(nameof(ShowEventsDialog), new ShowMeetingsDialogOptions(ShowMeetingsDialogOptions.ShowMeetingReason.FirstShowOverview, options));
await dc.BeginDialogAsync(nameof(ShowEventsDialog), new ShowMeetingsDialogOptions(ShowMeetingsDialogOptions.ShowMeetingReason.FirstShowOverview, options));
break;
}

case CalendarLuis.Intent.None:
{
if (generalTopIntent == General.Intent.ShowNext || generalTopIntent == General.Intent.ShowPrevious)
{
turnResult = await dc.BeginDialogAsync(nameof(ShowEventsDialog), new ShowMeetingsDialogOptions(ShowMeetingsDialogOptions.ShowMeetingReason.FirstShowOverview, options));
await dc.BeginDialogAsync(nameof(ShowEventsDialog), new ShowMeetingsDialogOptions(ShowMeetingsDialogOptions.ShowMeetingReason.FirstShowOverview, options));
}
else
{
await dc.Context.SendActivityAsync(_responseManager.GetResponse(CalendarSharedResponses.DidntUnderstandMessage));
turnResult = new DialogTurnResult(DialogTurnStatus.Complete);
}

break;
Expand All @@ -184,16 +182,9 @@ public MainDialog(
default:
{
await dc.Context.SendActivityAsync(_responseManager.GetResponse(CalendarMainResponses.FeatureNotAvailable));
turnResult = new DialogTurnResult(DialogTurnStatus.Complete);

break;
}
}

if (turnResult != EndOfTurn)
{
await CompleteAsync(dc);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Threading.Tasks;
using CalendarSkill.Responses.Shared;
using CalendarSkill.Services;
using CalendarSkillTest.Flow.Fakes;
using CalendarSkillTest.Flow.Utterances;
using Microsoft.Bot.Builder.AI.Luis;
using Microsoft.Bot.Builder.Solutions;
using Microsoft.Bot.Schema;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace CalendarSkillTest.Flow
{
[TestClass]
public class GeneralSkillFlowTests : CalendarBotTestBase
{
[TestInitialize]
public void SetupLuisService()
{
var botServices = Services.BuildServiceProvider().GetService<BotServices>();
botServices.CognitiveModelSets.Add("en", new CognitiveModelSet()
{
LuisServices = new Dictionary<string, ITelemetryRecognizer>()
{
{ "General", new MockLuisRecognizer() },
{ "Calendar", new MockLuisRecognizer(new BaseTestUtterances()) }
}
});
}

/// <summary>
/// Tests that single-turn conversations correctly call CompleteAsync on completion.
/// </summary>
/// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
[TestMethod]
public async Task Test_SingleTurnCompletion()
{
await this.GetTestFlow()
.Send(GeneralTestUtterances.UnknownIntent)
.AssertReplyOneOf(this.ConfusedResponse())
.AssertReply((activity) => { Assert.AreEqual(ActivityTypes.Handoff, activity.Type); })
.StartTestAsync();
}

private string[] ConfusedResponse()
{
return this.ParseReplies(CalendarSharedResponses.DidntUnderstandMessage, new StringDictionary());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ public GeneralTestUtterances()

public static string ChooseOne { get; } = "First one";

public static string UnknownIntent { get; } = "What's the weather?";

public General GetBaseNoneIntent()
{
var intent = new General
Expand Down
21 changes: 6 additions & 15 deletions skills/src/csharp/emailskill/emailskill/Dialogs/MainDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ public MainDialog(
}
else
{
var turnResult = EndOfTurn;
var intent = state.LuisResult?.TopIntent().intent;
var generalTopIntent = state.GeneralLuisResult?.TopIntent().intent;

Expand All @@ -104,19 +103,19 @@ public MainDialog(
{
case EmailLuis.Intent.SendEmail:
{
turnResult = await dc.BeginDialogAsync(nameof(SendEmailDialog), skillOptions);
await dc.BeginDialogAsync(nameof(SendEmailDialog), skillOptions);
break;
}

case EmailLuis.Intent.Forward:
{
turnResult = await dc.BeginDialogAsync(nameof(ForwardEmailDialog), skillOptions);
await dc.BeginDialogAsync(nameof(ForwardEmailDialog), skillOptions);
break;
}

case EmailLuis.Intent.Reply:
{
turnResult = await dc.BeginDialogAsync(nameof(ReplyEmailDialog), skillOptions);
await dc.BeginDialogAsync(nameof(ReplyEmailDialog), skillOptions);
break;
}

Expand All @@ -125,13 +124,13 @@ public MainDialog(
case EmailLuis.Intent.ReadAloud:
case EmailLuis.Intent.QueryLastText:
{
turnResult = await dc.BeginDialogAsync(nameof(ShowEmailDialog), skillOptions);
await dc.BeginDialogAsync(nameof(ShowEmailDialog), skillOptions);
break;
}

case EmailLuis.Intent.Delete:
{
turnResult = await dc.BeginDialogAsync(nameof(DeleteEmailDialog), skillOptions);
await dc.BeginDialogAsync(nameof(DeleteEmailDialog), skillOptions);
break;
}

Expand All @@ -144,12 +143,11 @@ public MainDialog(
|| generalTopIntent == General.Intent.ShowNext
|| generalTopIntent == General.Intent.ShowPrevious)
{
turnResult = await dc.BeginDialogAsync(nameof(ShowEmailDialog), skillOptions);
await dc.BeginDialogAsync(nameof(ShowEmailDialog), skillOptions);
}
else
{
await dc.Context.SendActivityAsync(_responseManager.GetResponse(EmailSharedResponses.DidntUnderstandMessage));
turnResult = new DialogTurnResult(DialogTurnStatus.Complete);
}

break;
Expand All @@ -158,16 +156,9 @@ public MainDialog(
default:
{
await dc.Context.SendActivityAsync(_responseManager.GetResponse(EmailMainResponses.FeatureNotAvailable));
turnResult = new DialogTurnResult(DialogTurnStatus.Complete);

break;
}
}

if (turnResult != EndOfTurn)
{
await CompleteAsync(dc);
}
}
}

Expand Down
3 changes: 0 additions & 3 deletions skills/src/csharp/emailskill/emailskill/EmailSkill.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
<TargetFramework>netcoreapp2.2</TargetFramework>
<UserSecretsId>3383fcc5-4017-4e0a-9103-68603b68fe1d</UserSecretsId>
<NoWarn>NU1701</NoWarn>
<RestoreAdditionalProjectSources>
https://botbuilder.myget.org/F/aitemplates/api/v3/index.json;
</RestoreAdditionalProjectSources>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System.Collections.Specialized;
using System.Threading.Tasks;
using EmailSkill.Responses.Shared;
using EmailSkillTest.Flow.Utterances;
using Microsoft.Bot.Schema;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace EmailSkillTest.Flow
{
[TestClass]
public class GeneralSkillFlowTests : EmailBotTestBase
{
[TestMethod]
public async Task Test_SingleTurnCompletion()
{
await this.GetTestFlow()
.Send(GeneralTestUtterances.UnknownIntent)
.AssertReplyOneOf(this.ConfusedResponse())
.AssertReply((activity) => { Assert.AreEqual(ActivityTypes.Handoff, activity.Type); })
.StartTestAsync();
}

private string[] ConfusedResponse()
{
return this.ParseReplies(EmailSharedResponses.DidntUnderstandMessage, new StringDictionary());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public GeneralTestUtterances()

public static string No { get; } = "No";

public static string UnknownIntent { get; } = "What's the weather?";

public General GetBaseNoneIntent()
{
var generalIntent = new General
Expand Down
Loading

0 comments on commit d3756df

Please sign in to comment.