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

Commit eb5bb60

Browse files
authored
[ToDo] Optimize flow for first-time user based on new design (#460)
* Init UserState * Store and recover ListTypeIds from UserState * Implement sending email to users when first initializing the OneNote or Outlook ToDo/Shopping/Grocery lists * move OneNote book name and section name to resource file * add email content and subject for first user login * Inject mail service and optimize ut based on new flow * fix unit tests to align with new flow * minor optimization * fix bugs of UserState storage * adjust test * fix typo * fix inconsistent actions when flow ends
1 parent 3652c33 commit eb5bb60

36 files changed

+674
-141
lines changed

solutions/Virtual-Assistant/src/csharp/skills/tests/todoskilltest/Flow/AddToDoFlowTests.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using System.Collections.Specialized;
66
using System.Threading.Tasks;
77
using AdaptiveCards;
8-
using Microsoft.Bot.Builder;
98
using Microsoft.Bot.Schema;
109
using Microsoft.Bot.Solutions;
1110
using Microsoft.Bot.Solutions.Skills;
@@ -45,6 +44,7 @@ await this.GetTestFlow()
4544
.AssertReplyOneOf(this.CollectToDoContent())
4645
.Send(AddToDoFlowTestUtterances.TaskContent)
4746
.AssertReplyOneOf(this.SettingUpOneNote())
47+
.AssertReplyOneOf(this.AfterSettingUpOneNote())
4848
.AssertReply(this.ShowUpdatedToDoList())
4949
.AssertReply(this.ActionEndMessage())
5050
.StartTestAsync();
@@ -58,6 +58,7 @@ await this.GetTestFlow()
5858
.AssertReply(this.ShowAuth())
5959
.Send(this.GetAuthResponse())
6060
.AssertReplyOneOf(this.SettingUpOneNote())
61+
.AssertReplyOneOf(this.AfterSettingUpOneNote())
6162
.AssertReply(this.ShowUpdatedGroceryList())
6263
.AssertReply(this.ActionEndMessage())
6364
.StartTestAsync();
@@ -71,6 +72,7 @@ await this.GetTestFlow()
7172
.AssertReply(this.ShowAuth())
7273
.Send(this.GetAuthResponse())
7374
.AssertReplyOneOf(this.SettingUpOneNote())
75+
.AssertReplyOneOf(this.AfterSettingUpOneNote())
7476
.AssertReply(this.ShowUpdatedGroceryList())
7577
.AssertReply(this.ActionEndMessage())
7678
.StartTestAsync();
@@ -84,6 +86,7 @@ await this.GetTestFlow()
8486
.AssertReply(this.ShowAuth())
8587
.Send(this.GetAuthResponse())
8688
.AssertReplyOneOf(this.SettingUpOneNote())
89+
.AssertReplyOneOf(this.AfterSettingUpOneNote())
8790
.AssertReply(this.ShowUpdatedShoppingList())
8891
.AssertReply(this.ActionEndMessage())
8992
.StartTestAsync();
@@ -96,7 +99,12 @@ private string[] CollectToDoContent()
9699

97100
private string[] SettingUpOneNote()
98101
{
99-
return this.ParseReplies(ToDoSharedResponses.SettingUpOneNoteMessage.Replies, new StringDictionary());
102+
return this.ParseReplies(ToDoSharedResponses.SettingUpOutlookMessage.Replies, new StringDictionary());
103+
}
104+
105+
private string[] AfterSettingUpOneNote()
106+
{
107+
return this.ParseReplies(ToDoSharedResponses.AfterOutlookSetupMessage.Replies, new StringDictionary());
100108
}
101109

102110
private Action<IActivity> ShowUpdatedToDoList()

solutions/Virtual-Assistant/src/csharp/skills/tests/todoskilltest/Flow/DeleteAllToDosFlowTests.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,12 @@
44
using System.Collections.Generic;
55
using System.Collections.Specialized;
66
using System.Threading.Tasks;
7-
using AdaptiveCards;
8-
using Microsoft.Bot.Builder;
97
using Microsoft.Bot.Schema;
108
using Microsoft.Bot.Solutions;
119
using Microsoft.Bot.Solutions.Skills;
1210
using Microsoft.VisualStudio.TestTools.UnitTesting;
1311
using ToDoSkill.Dialogs.DeleteToDo.Resources;
1412
using ToDoSkill.Dialogs.Shared.Resources;
15-
using ToDoSkill.Dialogs.ShowToDo.Resources;
1613
using ToDoSkillTest.Flow.Fakes;
1714
using ToDoSkillTest.Flow.Utterances;
1815

@@ -45,6 +42,7 @@ await this.GetTestFlow()
4542
.AssertReply(this.ShowAuth())
4643
.Send(this.GetAuthResponse())
4744
.AssertReplyOneOf(this.SettingUpOneNote())
45+
.AssertReplyOneOf(this.AfterSettingUpOneNote())
4846
.AssertReply(this.CollectConfirmation())
4947
.Send("yes")
5048
.AssertReply(this.AfterAllTasksDeletedTextMessage())
@@ -76,7 +74,12 @@ private Action<IActivity> AfterAllTasksDeletedTextMessage()
7674

7775
private string[] SettingUpOneNote()
7876
{
79-
return this.ParseReplies(ToDoSharedResponses.SettingUpOneNoteMessage.Replies, new StringDictionary());
77+
return this.ParseReplies(ToDoSharedResponses.SettingUpOutlookMessage.Replies, new StringDictionary());
78+
}
79+
80+
private string[] AfterSettingUpOneNote()
81+
{
82+
return this.ParseReplies(ToDoSharedResponses.AfterOutlookSetupMessage.Replies, new StringDictionary());
8083
}
8184

8285
private Action<IActivity> ShowAuth()

solutions/Virtual-Assistant/src/csharp/skills/tests/todoskilltest/Flow/DeleteToDoFlowTests.cs

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using System.Collections.Specialized;
66
using System.Threading.Tasks;
77
using AdaptiveCards;
8-
using Microsoft.Bot.Builder;
98
using Microsoft.Bot.Schema;
109
using Microsoft.Bot.Solutions;
1110
using Microsoft.Bot.Solutions.Skills;
@@ -33,15 +32,6 @@ public void SetupLuisService()
3332
});
3433
}
3534

36-
private static Dictionary<string, ITelemetryLuisRecognizer> NewMethod()
37-
{
38-
return new Dictionary<string, ITelemetryLuisRecognizer>()
39-
{
40-
{ "general", new MockLuisRecognizer(new GeneralTestUtterances()) },
41-
{ "todo", new MockLuisRecognizer(new DeleteToDoFlowTestUtterances()) }
42-
};
43-
}
44-
4535
[TestMethod]
4636
public async Task Test_DeleteToDoItem()
4737
{
@@ -50,6 +40,7 @@ await this.GetTestFlow()
5040
.AssertReply(this.ShowAuth())
5141
.Send(this.GetAuthResponse())
5242
.AssertReplyOneOf(this.SettingUpOneNote())
43+
.AssertReplyOneOf(this.AfterSettingUpOneNote())
5344
.AssertReplyOneOf(this.CollectTaskIndex())
5445
.Send(DeleteToDoFlowTestUtterances.TaskContent)
5546
.AssertReplyOneOf(this.CollectConfirmationForToDo())
@@ -67,6 +58,7 @@ await this.GetTestFlow()
6758
.AssertReply(this.ShowAuth())
6859
.Send(this.GetAuthResponse())
6960
.AssertReplyOneOf(this.SettingUpOneNote())
61+
.AssertReplyOneOf(this.AfterSettingUpOneNote())
7062
.AssertReplyOneOf(this.CollectConfirmationForToDo())
7163
.Send("yes")
7264
.AssertReply(this.AfterTaskDeletedCardMessage())
@@ -82,6 +74,7 @@ await this.GetTestFlow()
8274
.AssertReply(this.ShowAuth())
8375
.Send(this.GetAuthResponse())
8476
.AssertReplyOneOf(this.SettingUpOneNote())
77+
.AssertReplyOneOf(this.AfterSettingUpOneNote())
8578
.AssertReplyOneOf(this.CollectConfirmationForShopping())
8679
.Send("yes")
8780
.AssertReply(this.AfterShoppingItemDeletedCardMessage())
@@ -97,6 +90,7 @@ await this.GetTestFlow()
9790
.AssertReply(this.ShowAuth())
9891
.Send(this.GetAuthResponse())
9992
.AssertReplyOneOf(this.SettingUpOneNote())
93+
.AssertReplyOneOf(this.AfterSettingUpOneNote())
10094
.AssertReplyOneOf(this.CollectConfirmationForToDo())
10195
.Send("yes")
10296
.AssertReply(this.AfterTaskDeletedCardMessage())
@@ -113,6 +107,7 @@ await this.GetTestFlow()
113107
.AssertReply(this.ShowAuth())
114108
.Send(this.GetAuthResponse())
115109
.AssertReplyOneOf(this.SettingUpOneNote())
110+
.AssertReplyOneOf(this.AfterSettingUpOneNote())
116111
.AssertReplyOneOf(this.CollectConfirmationForToDo())
117112
.Send("yes")
118113
.AssertReply(this.AfterLastTaskDeletedMessage())
@@ -128,13 +123,23 @@ await this.GetTestFlow()
128123
.AssertReply(this.ShowAuth())
129124
.Send(this.GetAuthResponse())
130125
.AssertReplyOneOf(this.SettingUpOneNote())
126+
.AssertReplyOneOf(this.AfterSettingUpOneNote())
131127
.AssertReplyOneOf(this.CollectConfirmationForToDo())
132128
.Send("no")
133129
.AssertReplyOneOf(this.AfterDeletionRejectedMessage())
134130
.AssertReply(this.ActionEndMessage())
135131
.StartTestAsync();
136132
}
137133

134+
private static Dictionary<string, ITelemetryLuisRecognizer> NewMethod()
135+
{
136+
return new Dictionary<string, ITelemetryLuisRecognizer>()
137+
{
138+
{ "general", new MockLuisRecognizer(new GeneralTestUtterances()) },
139+
{ "todo", new MockLuisRecognizer(new DeleteToDoFlowTestUtterances()) }
140+
};
141+
}
142+
138143
private Action<IActivity> AfterTaskDeletedCardMessage()
139144
{
140145
return activity =>
@@ -225,7 +230,12 @@ private string[] CollectConfirmationForShopping()
225230

226231
private string[] SettingUpOneNote()
227232
{
228-
return this.ParseReplies(ToDoSharedResponses.SettingUpOneNoteMessage.Replies, new StringDictionary());
233+
return this.ParseReplies(ToDoSharedResponses.SettingUpOutlookMessage.Replies, new StringDictionary());
234+
}
235+
236+
private string[] AfterSettingUpOneNote()
237+
{
238+
return this.ParseReplies(ToDoSharedResponses.AfterOutlookSetupMessage.Replies, new StringDictionary());
229239
}
230240

231241
private Action<IActivity> ShowAuth()

solutions/Virtual-Assistant/src/csharp/skills/tests/todoskilltest/Flow/Fakes/MockData.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,5 +182,7 @@ public static class MockData
182182
IsCompleted = false
183183
}
184184
};
185+
186+
public static string MockOneNoteWebLink { get; set; } = "https://123456-my.sharepoint.com/personal/123456";
185187
}
186188
}

solutions/Virtual-Assistant/src/csharp/skills/tests/todoskilltest/Flow/Fakes/MockLuisRecognizer.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@ public class MockLuisRecognizer : ITelemetryLuisRecognizer
1515
private BaseTestUtterances utterancesManager;
1616
private GeneralTestUtterances generalUtterancesManager;
1717

18-
public bool LogOriginalMessage => throw new NotImplementedException();
19-
20-
public bool LogUsername => throw new NotImplementedException();
21-
2218
public MockLuisRecognizer(BaseTestUtterances utterancesManager)
2319
{
2420
this.utterancesManager = utterancesManager;
@@ -29,6 +25,10 @@ public MockLuisRecognizer(GeneralTestUtterances generalUtterancesMananger)
2925
this.generalUtterancesManager = generalUtterancesMananger;
3026
}
3127

28+
public bool LogOriginalMessage => throw new NotImplementedException();
29+
30+
public bool LogUsername => throw new NotImplementedException();
31+
3232
public Task<RecognizerResult> RecognizeAsync(ITurnContext turnContext, CancellationToken cancellationToken)
3333
{
3434
throw new NotImplementedException();
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
using System;
4+
using System.Collections.Generic;
5+
using System.Net.Http;
6+
using System.Threading.Tasks;
7+
using ToDoSkill;
8+
using ToDoSkillTest.Flow.Fakes;
9+
10+
namespace ToDoSkillTest.Fakes
11+
{
12+
public class MockMailService : IMailService
13+
{
14+
public MockMailService()
15+
{
16+
}
17+
18+
public Task<IMailService> InitAsync(string token)
19+
{
20+
return Task.FromResult(this as IMailService);
21+
}
22+
23+
public Task SendMessageAsync(string content, string subject)
24+
{
25+
return Task.CompletedTask;
26+
}
27+
28+
public Task<string> GetSenderMailAddressAsync()
29+
{
30+
return Task.FromResult("[email protected]");
31+
}
32+
}
33+
}

solutions/Virtual-Assistant/src/csharp/skills/tests/todoskilltest/Flow/Fakes/MockToDoService.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,5 +137,10 @@ public Task<bool> MarkTasksCompletedAsync(string listType, List<TaskItem> taskIt
137137

138138
return Task.FromResult(true);
139139
}
140+
141+
public Task<string> GetTaskWebLink()
142+
{
143+
return Task.FromResult(MockData.MockOneNoteWebLink);
144+
}
140145
}
141-
}
146+
}

solutions/Virtual-Assistant/src/csharp/skills/tests/todoskilltest/Flow/MarkAllToDosFlowTests.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,11 @@
55
using System.Collections.Specialized;
66
using System.Threading.Tasks;
77
using AdaptiveCards;
8-
using Microsoft.Bot.Builder;
98
using Microsoft.Bot.Schema;
109
using Microsoft.Bot.Solutions;
1110
using Microsoft.Bot.Solutions.Skills;
1211
using Microsoft.VisualStudio.TestTools.UnitTesting;
1312
using ToDoSkill.Dialogs.Shared.Resources;
14-
using ToDoSkill.Dialogs.ShowToDo.Resources;
1513
using ToDoSkillTest.Flow.Fakes;
1614
using ToDoSkillTest.Flow.Utterances;
1715

@@ -44,6 +42,7 @@ await this.GetTestFlow()
4442
.AssertReply(this.ShowAuth())
4543
.Send(this.GetAuthResponse())
4644
.AssertReplyOneOf(this.SettingUpOneNote())
45+
.AssertReplyOneOf(this.AfterSettingUpOneNote())
4746
.AssertReply(this.AfterAllTasksMarkedCardMessage())
4847
.AssertReply(this.ActionEndMessage())
4948
.StartTestAsync();
@@ -76,7 +75,12 @@ private Action<IActivity> AfterAllTasksMarkedCardMessage()
7675

7776
private string[] SettingUpOneNote()
7877
{
79-
return this.ParseReplies(ToDoSharedResponses.SettingUpOneNoteMessage.Replies, new StringDictionary());
78+
return this.ParseReplies(ToDoSharedResponses.SettingUpOutlookMessage.Replies, new StringDictionary());
79+
}
80+
81+
private string[] AfterSettingUpOneNote()
82+
{
83+
return this.ParseReplies(ToDoSharedResponses.AfterOutlookSetupMessage.Replies, new StringDictionary());
8084
}
8185

8286
private Action<IActivity> ShowAuth()

solutions/Virtual-Assistant/src/csharp/skills/tests/todoskilltest/Flow/MarkToDoFlowTests.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,11 @@
55
using System.Collections.Specialized;
66
using System.Threading.Tasks;
77
using AdaptiveCards;
8-
using Microsoft.Bot.Builder;
98
using Microsoft.Bot.Schema;
109
using Microsoft.Bot.Solutions;
1110
using Microsoft.Bot.Solutions.Skills;
1211
using Microsoft.VisualStudio.TestTools.UnitTesting;
1312
using ToDoSkill.Dialogs.Shared.Resources;
14-
using ToDoSkill.Dialogs.ShowToDo.Resources;
1513
using ToDoSkillTest.Flow.Fakes;
1614
using ToDoSkillTest.Flow.Utterances;
1715

@@ -44,6 +42,7 @@ await this.GetTestFlow()
4442
.AssertReply(this.ShowAuth())
4543
.Send(this.GetAuthResponse())
4644
.AssertReplyOneOf(this.SettingUpOneNote())
45+
.AssertReplyOneOf(this.AfterSettingUpOneNote())
4746
.AssertReplyOneOf(this.CollectTaskIndex())
4847
.Send(MarkToDoFlowTestUtterances.TaskContent)
4948
.AssertReply(this.AfterTaskMarkedCardMessage(0))
@@ -59,6 +58,7 @@ await this.GetTestFlow()
5958
.AssertReply(this.ShowAuth())
6059
.Send(this.GetAuthResponse())
6160
.AssertReplyOneOf(this.SettingUpOneNote())
61+
.AssertReplyOneOf(this.AfterSettingUpOneNote())
6262
.AssertReply(this.AfterTaskMarkedCardMessage(1))
6363
.AssertReply(this.ActionEndMessage())
6464
.StartTestAsync();
@@ -72,6 +72,7 @@ await this.GetTestFlow()
7272
.AssertReply(this.ShowAuth())
7373
.Send(this.GetAuthResponse())
7474
.AssertReplyOneOf(this.SettingUpOneNote())
75+
.AssertReplyOneOf(this.AfterSettingUpOneNote())
7576
.AssertReply(this.AfterGroceryItemMarkedCompletedCardMessage())
7677
.AssertReply(this.ActionEndMessage())
7778
.StartTestAsync();
@@ -85,6 +86,7 @@ await this.GetTestFlow()
8586
.AssertReply(this.ShowAuth())
8687
.Send(this.GetAuthResponse())
8788
.AssertReplyOneOf(this.SettingUpOneNote())
89+
.AssertReplyOneOf(this.AfterSettingUpOneNote())
8890
.AssertReply(this.AfterTaskMarkedCardMessage(0))
8991
.AssertReply(this.ActionEndMessage())
9092
.StartTestAsync();
@@ -149,7 +151,12 @@ private string[] CollectTaskIndex()
149151

150152
private string[] SettingUpOneNote()
151153
{
152-
return this.ParseReplies(ToDoSharedResponses.SettingUpOneNoteMessage.Replies, new StringDictionary());
154+
return this.ParseReplies(ToDoSharedResponses.SettingUpOutlookMessage.Replies, new StringDictionary());
155+
}
156+
157+
private string[] AfterSettingUpOneNote()
158+
{
159+
return this.ParseReplies(ToDoSharedResponses.AfterOutlookSetupMessage.Replies, new StringDictionary());
153160
}
154161

155162
private Action<IActivity> ShowAuth()

0 commit comments

Comments
 (0)