diff --git a/solutions/Virtual-Assistant/src/csharp/skills/emailskill/Dialogs/DeleteEmail/DeleteEmailDialog.cs b/solutions/Virtual-Assistant/src/csharp/skills/emailskill/Dialogs/DeleteEmail/DeleteEmailDialog.cs index a611265cb0..1b82909a11 100644 --- a/solutions/Virtual-Assistant/src/csharp/skills/emailskill/Dialogs/DeleteEmail/DeleteEmailDialog.cs +++ b/solutions/Virtual-Assistant/src/csharp/skills/emailskill/Dialogs/DeleteEmail/DeleteEmailDialog.cs @@ -1,9 +1,12 @@ using System; +using System.Collections.Specialized; using System.Linq; using System.Threading; using System.Threading.Tasks; using EmailSkill.Dialogs.DeleteEmail.Resources; using EmailSkill.Dialogs.Shared.Resources; +using EmailSkill.Dialogs.Shared.Resources.Strings; +using EmailSkill.Util; using Microsoft.Bot.Builder; using Microsoft.Bot.Builder.Dialogs; using Microsoft.Bot.Solutions.Extensions; @@ -64,10 +67,26 @@ public DeleteEmailDialog( var focusedMessage = state.Message?.FirstOrDefault(); if (focusedMessage != null) { - return await sc.PromptAsync(Actions.TakeFurtherAction, new PromptOptions { Prompt = sc.Context.Activity.CreateReply(DeleteEmailResponses.DeleteConfirm) }); + var nameListString = DisplayHelper.ToDisplayRecipientsString_Summay(focusedMessage.ToRecipients); + var emailCard = new EmailCardData + { + Subject = string.Format(EmailCommonStrings.SubjectFormat, focusedMessage.Subject), + NameList = string.Format(EmailCommonStrings.ToFormat, nameListString), + EmailContent = string.Format(EmailCommonStrings.ContentFormat, focusedMessage.BodyPreview), + }; + + var speech = SpeakHelper.ToSpeechEmailSendDetailString(focusedMessage.Subject, nameListString, focusedMessage.BodyPreview); + var stringToken = new StringDictionary + { + { "EmailDetails", speech }, + }; + var replyMessage = sc.Context.Activity.CreateAdaptiveCardReply(DeleteEmailResponses.DeleteConfirm, "Dialogs/Shared/Resources/Cards/EmailWithOutButtonCard.json", emailCard, ResponseBuilder, stringToken); + + return await sc.PromptAsync(Actions.TakeFurtherAction, new PromptOptions { Prompt = replyMessage, RetryPrompt = sc.Context.Activity.CreateReply(EmailSharedResponses.ConfirmSendFailed, ResponseBuilder), }); } - return await sc.BeginDialogAsync(Actions.Show, skillOptions); + skillOptions.SubFlowMode = true; + return await sc.BeginDialogAsync(Actions.UpdateSelectMessage, skillOptions); } catch (Exception ex) { diff --git a/solutions/Virtual-Assistant/src/csharp/skills/emailskill/Dialogs/DeleteEmail/Resources/DeleteEmailResponses.json b/solutions/Virtual-Assistant/src/csharp/skills/emailskill/Dialogs/DeleteEmail/Resources/DeleteEmailResponses.json index c903a7f213..abfbefbc23 100644 --- a/solutions/Virtual-Assistant/src/csharp/skills/emailskill/Dialogs/DeleteEmail/Resources/DeleteEmailResponses.json +++ b/solutions/Virtual-Assistant/src/csharp/skills/emailskill/Dialogs/DeleteEmail/Resources/DeleteEmailResponses.json @@ -24,7 +24,7 @@ "replies": [ { "text": "Are you sure you want to delete?", - "speak": "Are you sure you want to delete?" + "speak": "Are you sure you want to delete? Details of email: {EmailDetails}" } ], "inputHint": "expectingInput" diff --git a/solutions/Virtual-Assistant/src/csharp/skills/emailskill/Dialogs/DeleteEmail/Resources/DeleteEmailResponses.zh.json b/solutions/Virtual-Assistant/src/csharp/skills/emailskill/Dialogs/DeleteEmail/Resources/DeleteEmailResponses.zh.json index 92278e6dc2..44df2a89ba 100644 --- a/solutions/Virtual-Assistant/src/csharp/skills/emailskill/Dialogs/DeleteEmail/Resources/DeleteEmailResponses.zh.json +++ b/solutions/Virtual-Assistant/src/csharp/skills/emailskill/Dialogs/DeleteEmail/Resources/DeleteEmailResponses.zh.json @@ -11,8 +11,8 @@ "DeleteConfirm": { "replies": [ { - "text": "Ok, I'll delete this.", - "speak": "Ok, I'll delete this." + "text": "您确定要删除这封邮件么?", + "speak": "您确定要删除这封邮件么? 邮件内容: {EmailDetails}" } ], "inputHint": "expectingInput" @@ -20,8 +20,8 @@ "DeleteSuccessfully": { "replies": [ { - "text": "我已经删除了这个邮件。", - "speak": "我已经删除了这个邮件。" + "text": "我已经删除了这封邮件。", + "speak": "我已经删除了这封邮件。" } ], "inputHint": "acceptingInput" diff --git a/solutions/Virtual-Assistant/src/csharp/skills/emailskill/Dialogs/Main/MainDialog.cs b/solutions/Virtual-Assistant/src/csharp/skills/emailskill/Dialogs/Main/MainDialog.cs index 0c41539f9b..4117c63c50 100644 --- a/solutions/Virtual-Assistant/src/csharp/skills/emailskill/Dialogs/Main/MainDialog.cs +++ b/solutions/Virtual-Assistant/src/csharp/skills/emailskill/Dialogs/Main/MainDialog.cs @@ -109,6 +109,7 @@ public MainDialog(ISkillConfiguration skillConfiguration, ConversationState conv case Email.Intent.SearchMessages: case Email.Intent.CheckMessages: case Email.Intent.ReadAloud: + case Email.Intent.QueryLastText: { await dc.BeginDialogAsync(nameof(ShowEmailDialog), skillOptions); break; diff --git a/solutions/Virtual-Assistant/src/csharp/skills/emailskill/Dialogs/Shared/EmailSkillDialog.cs b/solutions/Virtual-Assistant/src/csharp/skills/emailskill/Dialogs/Shared/EmailSkillDialog.cs index 0b5b86c3e7..abe14f4a01 100644 --- a/solutions/Virtual-Assistant/src/csharp/skills/emailskill/Dialogs/Shared/EmailSkillDialog.cs +++ b/solutions/Virtual-Assistant/src/csharp/skills/emailskill/Dialogs/Shared/EmailSkillDialog.cs @@ -826,6 +826,7 @@ protected async Task GetPreviewNameListString(WaterfallStepContext sc, s break; case Actions.Reply: case Actions.Forward: + case Actions.Delete: default: nameListString = DisplayHelper.ToDisplayRecipientsString_Summay(state.Recipients); break; diff --git a/solutions/Virtual-Assistant/src/csharp/skills/tests/emailskilltest/Flow/DeleteEmailFlowTests.cs b/solutions/Virtual-Assistant/src/csharp/skills/tests/emailskilltest/Flow/DeleteEmailFlowTests.cs index 246a418c43..4ed4a032a9 100644 --- a/solutions/Virtual-Assistant/src/csharp/skills/tests/emailskilltest/Flow/DeleteEmailFlowTests.cs +++ b/solutions/Virtual-Assistant/src/csharp/skills/tests/emailskilltest/Flow/DeleteEmailFlowTests.cs @@ -32,7 +32,7 @@ await this.GetTestFlow() .AssertReply(this.ShowEmailList()) .AssertReplyOneOf(this.NoFocusMessage()) .Send(BaseTestUtterances.FirstOne) - .AssertReplyOneOf(this.DeleteConfirm()) + .AssertReply(this.DeleteConfirm()) .Send(GeneralTestUtterances.No) .AssertReplyOneOf(this.NotSendingMessage()) .AssertReply(this.ActionEndMessage()) @@ -49,7 +49,7 @@ await this.GetTestFlow() .AssertReply(this.ShowEmailList()) .AssertReplyOneOf(this.NoFocusMessage()) .Send(BaseTestUtterances.FirstOne) - .AssertReplyOneOf(this.DeleteConfirm()) + .AssertReply(this.DeleteConfirm()) .Send(GeneralTestUtterances.Yes) .AssertReplyOneOf(this.DeleteSuccess()) .AssertReply(this.ActionEndMessage()) @@ -71,9 +71,14 @@ private string[] DeleteSuccess() return this.ParseReplies(DeleteEmailResponses.DeleteSuccessfully.Replies, new StringDictionary()); } - private string[] DeleteConfirm() + private Action DeleteConfirm() { - return this.ParseReplies(DeleteEmailResponses.DeleteConfirm.Replies, new StringDictionary()); + return activity => + { + var messageActivity = activity.AsMessageActivity(); + CollectionAssert.Contains(this.ParseReplies(DeleteEmailResponses.DeleteConfirm.Replies, new StringDictionary()), messageActivity.Text); + Assert.AreEqual(messageActivity.Attachments.Count, 1); + }; } private Action ActionEndMessage()