Skip to content

Commit

Permalink
Fix email detail reading and email delete issue (microsoft#220)
Browse files Browse the repository at this point in the history
* fix bugs

* fix default read

* fix doc

* remove english item in de (microsoft#239)
  • Loading branch information
DingmaomaoBJTU authored Nov 9, 2018
1 parent 2ca6b72 commit b3bd949
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ The [Add Authentication to your bot](https://docs.microsoft.com/en-us/azure/bot-
- Leave Logout URL blank.
- Under Microsoft Graph Permissions, you can need to add additional *delegated* permissions.
- Each of the Skills require a specific set of Scopes, refer to the documentation for each skill or use the following list of Scopes that contain the scopes needed for all skills.
- `Calendars.ReadWrite`, `Mail.Read`, `Mail.Send`, `Notes.ReadWrite`, `People.Read`, `User.Read`
- `Calendars.ReadWrite`, `Mail.ReadWrite`, `Mail.Send`, `Notes.ReadWrite`, `People.Read`, `User.Read`, `Contacts.Read`

Next you need to create the Authentication Connection for your Bot. Ensure you use the same combination of Scopes that you provided in the above command. The first command shown below will retrieve the appId (ApplicationId) and appPassword (Client Secret) that you need to complete this step.

Expand All @@ -149,7 +149,7 @@ The commands shown below assume you have used the deployment process and your re
```shell
msbot get production --secret YOUR_SECRET

az bot authsetting create --resource-group YOUR_BOT_NAME --name YOUR_BOT_NAME --setting-name "YOUR_AUTH_CONNECTION_NAME" --client-id "YOUR_APPLICATION_ID" --client-secret "YOUR_APPLICATION_PASSWORD" --provider-scope-string "Calendars.ReadWrite Mail.Read Mail.Send Notes.ReadWrite People.Read User.Read" --service Aadv2
az bot authsetting create --resource-group YOUR_BOT_NAME --name YOUR_BOT_NAME --setting-name "YOUR_AUTH_CONNECTION_NAME" --client-id "YOUR_APPLICATION_ID" --client-secret "YOUR_APPLICATION_PASSWORD" --provider-scope-string "Calendars.ReadWrite Mail.ReadWrite Mail.Send Notes.ReadWrite People.Read User.Read Contacts.Read" --service Aadv2
```

The final step is to update your .bot file and associated Skills (in appSettings.config) with the Authentication connection name, this is used by the Assistant to enable Authentication prompts or use of Linked Accounts.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,13 +360,9 @@
},
"ReadOutMessage": {
"replies": [
{
"text": "Email-Details:",
"speak": "Email-Details:"
},
{
"text": "Email Inhalte:",
"speak": "Email Inhalte:"
"speak": "Email Inhalte: {EmailDetails}"
}
],
"inputHint": "expectingInput"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@
"replies": [
{
"text": "Details of email:",
"speak": "Details of email"
"speak": "Details of email: {EmailDetails}"
},
{
"text": "Content of email:",
"speak": "Content of email:"
"speak": "Details of email: {EmailDetails}"
}
],
"inputHint": "expectingInput"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@
"replies": [
{
"text": "电子邮件详情:",
"speak": "电子邮件详情:"
"speak": "电子邮件详情:{EmailDetails}"
},
{
"text": "电子邮件内容:",
"speak": "电子邮件内容:"
"speak": "电子邮件内容:{EmailDetails}"
}
],
"inputHint": "expectingInput"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Microsoft.Bot.Solutions.Extensions;
using Microsoft.Bot.Solutions.Skills;
using System;
using System.Collections.Specialized;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
Expand Down Expand Up @@ -131,11 +132,6 @@ public ShowEmailDialog(
return await sc.EndDialogAsync(true);
}

if (topIntent == Email.Intent.Delete)
{
return await sc.BeginDialogAsync(nameof(DeleteEmailDialog));
}

return await sc.BeginDialogAsync(Action.Read);
}
catch (Exception ex)
Expand Down Expand Up @@ -196,7 +192,10 @@ await sc.Context.SendActivityAsync(
: message.ReceivedDateTime.Value.UtcDateTime.ToRelativeString(state.GetUserTimeZone()),
Speak = message?.Subject + " From " + message?.Sender.EmailAddress.Name + " " + message?.BodyPreview,
};
var replyMessage = sc.Context.Activity.CreateAdaptiveCardReply(ShowEmailResponses.ReadOutMessage, "Dialogs/Shared/Resources/Cards/EmailDetailCard.json", emailCard);

// Todo: workaround here to read out email details. Ignore body for now as we need a summary and filter.
var emailDetails = message?.Subject + " From " + message?.Sender.EmailAddress.Name;
var replyMessage = sc.Context.Activity.CreateAdaptiveCardReply(ShowEmailResponses.ReadOutMessage, "Dialogs/Shared/Resources/Cards/EmailDetailCard.json", emailCard, null, new StringDictionary() { { "EmailDetails", emailDetails } });
await sc.Context.SendActivityAsync(replyMessage);

return await sc.PromptAsync(Action.Prompt, new PromptOptions { Prompt = sc.Context.Activity.CreateReply(ShowEmailResponses.ReadOutMorePrompt) });
Expand Down Expand Up @@ -225,6 +224,11 @@ await sc.Context.SendActivityAsync(
return await sc.EndDialogAsync(true);
}

if (topIntent == Email.Intent.Delete)
{
return await sc.BeginDialogAsync(nameof(DeleteEmailDialog));
}

if (topIntent == Email.Intent.ReadAloud || topIntent == Email.Intent.SelectItem)
{
return await sc.BeginDialogAsync(Action.Read);
Expand Down

0 comments on commit b3bd949

Please sign in to comment.