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

Commit d3756df

Browse files
authored
Skill project updates (#2371)
* 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
1 parent 1d2cefa commit d3756df

File tree

45 files changed

+333
-257
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+333
-257
lines changed

skills/src/csharp/Directory.Build.props

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
<PropertyGroup>
33
<CodeAnalysisRuleSet>$(SolutionDir)..\..\..\VirtualAssistant.ruleset</CodeAnalysisRuleSet>
44
</PropertyGroup>
5+
6+
<PropertyGroup>
7+
<RestoreAdditionalProjectSources>
8+
https://botbuilder.myget.org/F/aitemplates/api/v3/index.json;
9+
</RestoreAdditionalProjectSources>
10+
</PropertyGroup>
511

612
<ItemGroup>
713
<PackageReference Include="StyleCop.Analyzers" Version="1.1.0-beta008" PrivateAssets="all" />

skills/src/csharp/automotiveskill/automotiveskill/Dialogs/MainDialog.cs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
using Microsoft.Bot.Builder;
1515
using Microsoft.Bot.Builder.Dialogs;
1616
using Microsoft.Bot.Builder.Dialogs.Choices;
17-
using Microsoft.Bot.Builder.Solutions;
1817
using Microsoft.Bot.Builder.Skills.Models;
18+
using Microsoft.Bot.Builder.Solutions;
1919
using Microsoft.Bot.Builder.Solutions.Dialogs;
2020
using Microsoft.Bot.Builder.Solutions.Responses;
2121
using Microsoft.Bot.Connector;
@@ -73,7 +73,6 @@ public MainDialog(
7373
}
7474
else
7575
{
76-
var turnResult = EndOfTurn;
7776
var result = await luisService.RecognizeAsync<Luis.SettingsLuis>(dc.Context, CancellationToken.None);
7877
var intent = result?.TopIntent().intent;
7978

@@ -87,31 +86,22 @@ public MainDialog(
8786
case SettingsLuis.Intent.VEHICLE_SETTINGS_DECLARATIVE:
8887
case SettingsLuis.Intent.VEHICLE_SETTINGS_CHECK:
8988
{
90-
turnResult = await dc.BeginDialogAsync(nameof(VehicleSettingsDialog));
89+
await dc.BeginDialogAsync(nameof(VehicleSettingsDialog));
9190
break;
9291
}
9392

9493
case SettingsLuis.Intent.None:
9594
{
9695
await dc.Context.SendActivityAsync(_responseManager.GetResponse(AutomotiveSkillSharedResponses.DidntUnderstandMessage));
97-
turnResult = new DialogTurnResult(DialogTurnStatus.Complete);
98-
9996
break;
10097
}
10198

10299
default:
103100
{
104101
await dc.Context.SendActivityAsync(_responseManager.GetResponse(AutomotiveSkillMainResponses.FeatureNotAvailable));
105-
turnResult = new DialogTurnResult(DialogTurnStatus.Complete);
106-
107102
break;
108103
}
109104
}
110-
111-
if (turnResult != EndOfTurn)
112-
{
113-
await CompleteAsync(dc);
114-
}
115105
}
116106
}
117107

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System.Collections.Specialized;
2+
using System.Threading.Tasks;
3+
using AutomotiveSkill.Responses.Shared;
4+
using Microsoft.Bot.Schema;
5+
using Microsoft.VisualStudio.TestTools.UnitTesting;
6+
7+
namespace AutomotiveSkillTest.Flow
8+
{
9+
[TestClass]
10+
public class GeneralSkillFlowTests : AutomotiveSkillTestBase
11+
{
12+
[TestMethod]
13+
public async Task Test_SingleTurnCompletion()
14+
{
15+
await this.GetTestFlow()
16+
.Send("what's the weather?")
17+
.AssertReplyOneOf(this.ConfusedResponse())
18+
.AssertReply((activity) => { Assert.AreEqual(ActivityTypes.Handoff, activity.Type); })
19+
.StartTestAsync();
20+
}
21+
22+
private string[] ConfusedResponse()
23+
{
24+
return this.ParseReplies(AutomotiveSkillSharedResponses.DidntUnderstandMessage, new StringDictionary());
25+
}
26+
}
27+
}

skills/src/csharp/calendarskill/calendarskill/CalendarSkill.csproj

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
<TargetFramework>netcoreapp2.2</TargetFramework>
55
<UserSecretsId>2bdd896c-393e-47c4-b6b9-a47238550b83</UserSecretsId>
66
<NoWarn>NU1701</NoWarn>
7-
<RestoreAdditionalProjectSources>
8-
https://botbuilder.myget.org/F/aitemplates/api/v3/index.json;
9-
</RestoreAdditionalProjectSources>
107
</PropertyGroup>
118

129
<ItemGroup>

skills/src/csharp/calendarskill/calendarskill/Dialogs/MainDialog.cs

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ public MainDialog(
104104
}
105105
else
106106
{
107-
var turnResult = EndOfTurn;
108107
var intent = state.LuisResult?.TopIntent().intent;
109108
var generalTopIntent = state.GeneralLuisResult?.TopIntent().intent;
110109

@@ -114,31 +113,31 @@ public MainDialog(
114113
case CalendarLuis.Intent.FindMeetingRoom:
115114
case CalendarLuis.Intent.CreateCalendarEntry:
116115
{
117-
turnResult = await dc.BeginDialogAsync(nameof(CreateEventDialog), options);
116+
await dc.BeginDialogAsync(nameof(CreateEventDialog), options);
118117
break;
119118
}
120119

121120
case CalendarLuis.Intent.AcceptEventEntry:
122121
{
123-
turnResult = await dc.BeginDialogAsync(nameof(ChangeEventStatusDialog), new ChangeEventStatusDialogOptions(options, EventStatus.Accepted));
122+
await dc.BeginDialogAsync(nameof(ChangeEventStatusDialog), new ChangeEventStatusDialogOptions(options, EventStatus.Accepted));
124123
break;
125124
}
126125

127126
case CalendarLuis.Intent.DeleteCalendarEntry:
128127
{
129-
turnResult = await dc.BeginDialogAsync(nameof(ChangeEventStatusDialog), new ChangeEventStatusDialogOptions(options, EventStatus.Cancelled));
128+
await dc.BeginDialogAsync(nameof(ChangeEventStatusDialog), new ChangeEventStatusDialogOptions(options, EventStatus.Cancelled));
130129
break;
131130
}
132131

133132
case CalendarLuis.Intent.ChangeCalendarEntry:
134133
{
135-
turnResult = await dc.BeginDialogAsync(nameof(UpdateEventDialog), options);
134+
await dc.BeginDialogAsync(nameof(UpdateEventDialog), options);
136135
break;
137136
}
138137

139138
case CalendarLuis.Intent.ConnectToMeeting:
140139
{
141-
turnResult = await dc.BeginDialogAsync(nameof(JoinEventDialog), options);
140+
await dc.BeginDialogAsync(nameof(JoinEventDialog), options);
142141
break;
143142
}
144143

@@ -149,33 +148,32 @@ public MainDialog(
149148
case CalendarLuis.Intent.FindCalendarWho:
150149
case CalendarLuis.Intent.FindDuration:
151150
{
152-
turnResult = await dc.BeginDialogAsync(nameof(ShowEventsDialog), new ShowMeetingsDialogOptions(ShowMeetingsDialogOptions.ShowMeetingReason.FirstShowOverview, options));
151+
await dc.BeginDialogAsync(nameof(ShowEventsDialog), new ShowMeetingsDialogOptions(ShowMeetingsDialogOptions.ShowMeetingReason.FirstShowOverview, options));
153152
break;
154153
}
155154

156155
case CalendarLuis.Intent.TimeRemaining:
157156
{
158-
turnResult = await dc.BeginDialogAsync(nameof(TimeRemainingDialog));
157+
await dc.BeginDialogAsync(nameof(TimeRemainingDialog));
159158
break;
160159
}
161160

162161
case CalendarLuis.Intent.ShowNextCalendar:
163162
case CalendarLuis.Intent.ShowPreviousCalendar:
164163
{
165-
turnResult = await dc.BeginDialogAsync(nameof(ShowEventsDialog), new ShowMeetingsDialogOptions(ShowMeetingsDialogOptions.ShowMeetingReason.FirstShowOverview, options));
164+
await dc.BeginDialogAsync(nameof(ShowEventsDialog), new ShowMeetingsDialogOptions(ShowMeetingsDialogOptions.ShowMeetingReason.FirstShowOverview, options));
166165
break;
167166
}
168167

169168
case CalendarLuis.Intent.None:
170169
{
171170
if (generalTopIntent == General.Intent.ShowNext || generalTopIntent == General.Intent.ShowPrevious)
172171
{
173-
turnResult = await dc.BeginDialogAsync(nameof(ShowEventsDialog), new ShowMeetingsDialogOptions(ShowMeetingsDialogOptions.ShowMeetingReason.FirstShowOverview, options));
172+
await dc.BeginDialogAsync(nameof(ShowEventsDialog), new ShowMeetingsDialogOptions(ShowMeetingsDialogOptions.ShowMeetingReason.FirstShowOverview, options));
174173
}
175174
else
176175
{
177176
await dc.Context.SendActivityAsync(_responseManager.GetResponse(CalendarSharedResponses.DidntUnderstandMessage));
178-
turnResult = new DialogTurnResult(DialogTurnStatus.Complete);
179177
}
180178

181179
break;
@@ -184,16 +182,9 @@ public MainDialog(
184182
default:
185183
{
186184
await dc.Context.SendActivityAsync(_responseManager.GetResponse(CalendarMainResponses.FeatureNotAvailable));
187-
turnResult = new DialogTurnResult(DialogTurnStatus.Complete);
188-
189185
break;
190186
}
191187
}
192-
193-
if (turnResult != EndOfTurn)
194-
{
195-
await CompleteAsync(dc);
196-
}
197188
}
198189
}
199190

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
using System.Collections.Generic;
2+
using System.Collections.Specialized;
3+
using System.Threading.Tasks;
4+
using CalendarSkill.Responses.Shared;
5+
using CalendarSkill.Services;
6+
using CalendarSkillTest.Flow.Fakes;
7+
using CalendarSkillTest.Flow.Utterances;
8+
using Microsoft.Bot.Builder.AI.Luis;
9+
using Microsoft.Bot.Builder.Solutions;
10+
using Microsoft.Bot.Schema;
11+
using Microsoft.Extensions.DependencyInjection;
12+
using Microsoft.VisualStudio.TestTools.UnitTesting;
13+
14+
namespace CalendarSkillTest.Flow
15+
{
16+
[TestClass]
17+
public class GeneralSkillFlowTests : CalendarBotTestBase
18+
{
19+
[TestInitialize]
20+
public void SetupLuisService()
21+
{
22+
var botServices = Services.BuildServiceProvider().GetService<BotServices>();
23+
botServices.CognitiveModelSets.Add("en", new CognitiveModelSet()
24+
{
25+
LuisServices = new Dictionary<string, ITelemetryRecognizer>()
26+
{
27+
{ "General", new MockLuisRecognizer() },
28+
{ "Calendar", new MockLuisRecognizer(new BaseTestUtterances()) }
29+
}
30+
});
31+
}
32+
33+
/// <summary>
34+
/// Tests that single-turn conversations correctly call CompleteAsync on completion.
35+
/// </summary>
36+
/// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
37+
[TestMethod]
38+
public async Task Test_SingleTurnCompletion()
39+
{
40+
await this.GetTestFlow()
41+
.Send(GeneralTestUtterances.UnknownIntent)
42+
.AssertReplyOneOf(this.ConfusedResponse())
43+
.AssertReply((activity) => { Assert.AreEqual(ActivityTypes.Handoff, activity.Type); })
44+
.StartTestAsync();
45+
}
46+
47+
private string[] ConfusedResponse()
48+
{
49+
return this.ParseReplies(CalendarSharedResponses.DidntUnderstandMessage, new StringDictionary());
50+
}
51+
}
52+
}

skills/src/csharp/calendarskill/calendarskilltest/Flow/Utterances/GeneralTestUtterances.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ public GeneralTestUtterances()
1515

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

18+
public static string UnknownIntent { get; } = "What's the weather?";
19+
1820
public General GetBaseNoneIntent()
1921
{
2022
var intent = new General

skills/src/csharp/emailskill/emailskill/Dialogs/MainDialog.cs

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ public MainDialog(
9090
}
9191
else
9292
{
93-
var turnResult = EndOfTurn;
9493
var intent = state.LuisResult?.TopIntent().intent;
9594
var generalTopIntent = state.GeneralLuisResult?.TopIntent().intent;
9695

@@ -104,19 +103,19 @@ public MainDialog(
104103
{
105104
case EmailLuis.Intent.SendEmail:
106105
{
107-
turnResult = await dc.BeginDialogAsync(nameof(SendEmailDialog), skillOptions);
106+
await dc.BeginDialogAsync(nameof(SendEmailDialog), skillOptions);
108107
break;
109108
}
110109

111110
case EmailLuis.Intent.Forward:
112111
{
113-
turnResult = await dc.BeginDialogAsync(nameof(ForwardEmailDialog), skillOptions);
112+
await dc.BeginDialogAsync(nameof(ForwardEmailDialog), skillOptions);
114113
break;
115114
}
116115

117116
case EmailLuis.Intent.Reply:
118117
{
119-
turnResult = await dc.BeginDialogAsync(nameof(ReplyEmailDialog), skillOptions);
118+
await dc.BeginDialogAsync(nameof(ReplyEmailDialog), skillOptions);
120119
break;
121120
}
122121

@@ -125,13 +124,13 @@ public MainDialog(
125124
case EmailLuis.Intent.ReadAloud:
126125
case EmailLuis.Intent.QueryLastText:
127126
{
128-
turnResult = await dc.BeginDialogAsync(nameof(ShowEmailDialog), skillOptions);
127+
await dc.BeginDialogAsync(nameof(ShowEmailDialog), skillOptions);
129128
break;
130129
}
131130

132131
case EmailLuis.Intent.Delete:
133132
{
134-
turnResult = await dc.BeginDialogAsync(nameof(DeleteEmailDialog), skillOptions);
133+
await dc.BeginDialogAsync(nameof(DeleteEmailDialog), skillOptions);
135134
break;
136135
}
137136

@@ -144,12 +143,11 @@ public MainDialog(
144143
|| generalTopIntent == General.Intent.ShowNext
145144
|| generalTopIntent == General.Intent.ShowPrevious)
146145
{
147-
turnResult = await dc.BeginDialogAsync(nameof(ShowEmailDialog), skillOptions);
146+
await dc.BeginDialogAsync(nameof(ShowEmailDialog), skillOptions);
148147
}
149148
else
150149
{
151150
await dc.Context.SendActivityAsync(_responseManager.GetResponse(EmailSharedResponses.DidntUnderstandMessage));
152-
turnResult = new DialogTurnResult(DialogTurnStatus.Complete);
153151
}
154152

155153
break;
@@ -158,16 +156,9 @@ public MainDialog(
158156
default:
159157
{
160158
await dc.Context.SendActivityAsync(_responseManager.GetResponse(EmailMainResponses.FeatureNotAvailable));
161-
turnResult = new DialogTurnResult(DialogTurnStatus.Complete);
162-
163159
break;
164160
}
165161
}
166-
167-
if (turnResult != EndOfTurn)
168-
{
169-
await CompleteAsync(dc);
170-
}
171162
}
172163
}
173164

skills/src/csharp/emailskill/emailskill/EmailSkill.csproj

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
<TargetFramework>netcoreapp2.2</TargetFramework>
55
<UserSecretsId>3383fcc5-4017-4e0a-9103-68603b68fe1d</UserSecretsId>
66
<NoWarn>NU1701</NoWarn>
7-
<RestoreAdditionalProjectSources>
8-
https://botbuilder.myget.org/F/aitemplates/api/v3/index.json;
9-
</RestoreAdditionalProjectSources>
107
</PropertyGroup>
118

129
<ItemGroup>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using System.Collections.Specialized;
2+
using System.Threading.Tasks;
3+
using EmailSkill.Responses.Shared;
4+
using EmailSkillTest.Flow.Utterances;
5+
using Microsoft.Bot.Schema;
6+
using Microsoft.VisualStudio.TestTools.UnitTesting;
7+
8+
namespace EmailSkillTest.Flow
9+
{
10+
[TestClass]
11+
public class GeneralSkillFlowTests : EmailBotTestBase
12+
{
13+
[TestMethod]
14+
public async Task Test_SingleTurnCompletion()
15+
{
16+
await this.GetTestFlow()
17+
.Send(GeneralTestUtterances.UnknownIntent)
18+
.AssertReplyOneOf(this.ConfusedResponse())
19+
.AssertReply((activity) => { Assert.AreEqual(ActivityTypes.Handoff, activity.Type); })
20+
.StartTestAsync();
21+
}
22+
23+
private string[] ConfusedResponse()
24+
{
25+
return this.ParseReplies(EmailSharedResponses.DidntUnderstandMessage, new StringDictionary());
26+
}
27+
}
28+
}

0 commit comments

Comments
 (0)