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

[Email Skill]Adaptive Card update with Graph API #1029

Merged
merged 24 commits into from
Apr 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/virtual-assistant/gettingstarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ The [Add Authentication to your bot](https://docs.microsoft.com/en-us/azure/bot-
- `Notes.ReadWrite`
- `People.Read`
- `Tasks.ReadWrite`
- `User.Read`
- `User.ReadBasic.All`
- Click Add Permissions at the bottom to apply the changes.

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 @@ -210,7 +210,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_DISPLAY_NAME" --client-id "YOUR_APPLICATION_ID" --client-secret "YOUR_APPLICATION_PASSWORD" --service Aadv2 --parameters clientId="YOUR_APPLICATION_ID" clientSecret="YOUR_APPLICATION_PASSWORD" tenantId=common --provider-scope-string "Calendars.ReadWrite Mail.ReadWrite Mail.Send Tasks.ReadWrite Notes.ReadWrite People.Read User.Read Contacts.Read"
az bot authsetting create --resource-group YOUR_BOT_NAME --name YOUR_BOT_NAME --setting-name "YOUR_AUTH_CONNECTION_DISPLAY_NAME" --client-id "YOUR_APPLICATION_ID" --client-secret "YOUR_APPLICATION_PASSWORD" --service Aadv2 --parameters clientId="YOUR_APPLICATION_ID" clientSecret="YOUR_APPLICATION_PASSWORD" tenantId=common --provider-scope-string "Calendars.ReadWrite Mail.ReadWrite Mail.Send Tasks.ReadWrite Notes.ReadWrite People.Read User.ReadBasic.All Contacts.Read"
```

> NOTE: Take special care when running the `authsetting` commands to correctly escape special characters in your client secret key (or parameters that contain special characters).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<PackageReference Include="Microsoft.Bot.Builder.Dialogs" Version="4.3.1" />
<PackageReference Include="Microsoft.Bot.Builder.Integration.ApplicationInsights.Core" Version="4.3.1" />
<PackageReference Include="Microsoft.Bot.Builder.Integration.AspNet.Core" Version="4.3.1" />
<PackageReference Include="Microsoft.Bot.Builder.Solutions" Version="4.4.0-preview-3" />
<PackageReference Include="Microsoft.Bot.Builder.Solutions" Version="4.4.24-preview" />
<PackageReference Include="Microsoft.Bot.Builder.TemplateManager" Version="4.3.1" />
<PackageReference Include="Microsoft.Bot.Configuration" Version="4.3.1" />
<PackageReference Include="Microsoft.Bot.Connector" Version="4.3.1" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<PackageReference Include="Microsoft.Bot.Builder.Dialogs" Version="4.3.1" />
<PackageReference Include="Microsoft.Bot.Builder.Integration.ApplicationInsights.Core" Version="4.3.1" />
<PackageReference Include="Microsoft.Bot.Builder.Integration.AspNet.Core" Version="4.3.1" />
<PackageReference Include="Microsoft.Bot.Builder.Solutions" Version="4.4.0-preview-3" />
<PackageReference Include="Microsoft.Bot.Builder.Solutions" Version="4.4.24-preview" />
<PackageReference Include="Microsoft.Bot.Builder.TemplateManager" Version="4.3.1" />
<PackageReference Include="Microsoft.Bot.Configuration" Version="4.3.1" />
<PackageReference Include="Microsoft.Bot.Connector" Version="4.3.1" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<PackageReference Include="Microsoft.Bot.Builder.Dialogs" Version="4.3.1" />
<PackageReference Include="Microsoft.Bot.Builder.Integration.ApplicationInsights.Core" Version="4.3.1" />
<PackageReference Include="Microsoft.Bot.Builder.Integration.AspNet.Core" Version="4.3.1" />
<PackageReference Include="Microsoft.Bot.Builder.Solutions" Version="4.4.0-preview-3" />
<PackageReference Include="Microsoft.Bot.Builder.Solutions" Version="4.4.24-preview" />
<PackageReference Include="Microsoft.Bot.Builder.TemplateManager" Version="4.3.1" />
<PackageReference Include="Microsoft.Bot.Configuration" Version="4.3.1" />
<PackageReference Include="Microsoft.Bot.Schema" Version="4.3.1" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<PackageReference Include="Microsoft.Bot.Builder.Dialogs" Version="4.3.1" />
<PackageReference Include="Microsoft.Bot.Builder.Integration.ApplicationInsights.Core" Version="4.3.1" />
<PackageReference Include="Microsoft.Bot.Builder.Integration.AspNet.Core" Version="4.3.1" />
<PackageReference Include="Microsoft.Bot.Builder.Solutions" Version="4.4.0-preview-3" />
<PackageReference Include="Microsoft.Bot.Builder.Solutions" Version="4.4.24-preview" />
<PackageReference Include="Microsoft.Bot.Builder.TemplateManager" Version="4.3.1" />
<PackageReference Include="Microsoft.Bot.Configuration" Version="4.3.1" />
<PackageReference Include="Microsoft.Bot.Connector" Version="4.3.1" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" />
<PackageReference Include="Microsoft.Bot.Builder.Solutions" Version="4.4.0-preview-3" />
<PackageReference Include="Microsoft.Bot.Builder.Solutions" Version="4.4.24-preview" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.0.0-preview-20190203-03" />
<PackageReference Include="MSTest.TestAdapter" Version="2.0.0-beta2" />
<PackageReference Include="MSTest.TestFramework" Version="2.0.0-beta2" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<PackageReference Include="Microsoft.Bot.Builder.Dialogs" Version="4.3.1" />
<PackageReference Include="Microsoft.Bot.Builder.Integration.ApplicationInsights.Core" Version="4.3.1" />
<PackageReference Include="Microsoft.Bot.Builder.Integration.AspNet.Core" Version="4.3.1" />
<PackageReference Include="Microsoft.Bot.Builder.Solutions" Version="4.4.0-preview-3" />
<PackageReference Include="Microsoft.Bot.Builder.Solutions" Version="4.4.24-preview" />
<PackageReference Include="Microsoft.Bot.Builder.TemplateManager" Version="4.3.1" />
<PackageReference Include="Microsoft.Bot.Configuration" Version="4.3.1" />
<PackageReference Include="Microsoft.Bot.Connector" Version="4.3.1" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public ChangeEventStatusDialog(
}

var card = new Card(deleteEvent.OnlineMeetingUrl == null ? "CalendarCardNoJoinButton" : "CalendarCard", deleteEvent.ToAdaptiveCardData(state.GetUserTimeZone()));
var replyMessage = ResponseManager.GetCardResponse(replyResponse, card);
var replyMessage = ResponseManager.GetCardResponse(replyResponse, card, tokens: null);
var retryMessage = ResponseManager.GetResponse(retryResponse);

return await sc.PromptAsync(Actions.TakeFurtherAction, new PromptOptions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ public UpdateEventDialog(
{
Name = origin.OnlineMeetingUrl == null ? "CalendarCardNoJoinButton" : "CalendarCard",
Data = origin.ToAdaptiveCardData(state.GetUserTimeZone())
});
},
tokens: null);

return await sc.PromptAsync(Actions.TakeFurtherAction, new PromptOptions
{
Expand Down Expand Up @@ -162,7 +163,8 @@ public UpdateEventDialog(
{
Name = newEvent.OnlineMeetingUrl == null ? "CalendarCardNoJoinButton" : "CalendarCard",
Data = newEvent.ToAdaptiveCardData(state.GetUserTimeZone())
});
},
tokens: null);

await sc.Context.SendActivityAsync(replyMessage);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public async Task<PersonModel> GetMe()
{
throw GoogleClient.HandleGoogleAPIException(ex);
}
}
}

// get people work with
private async Task<List<Person>> GetGooglePeopleAsync(string name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" />
<PackageReference Include="Autofac.Extras.Moq" Version="4.3.0" />
<PackageReference Include="Microsoft.Bot.Builder.Solutions" Version="4.4.0-preview-3" />
<PackageReference Include="Microsoft.Bot.Builder.Solutions" Version="4.4.24-preview" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.2" />
<PackageReference Include="MSTest.TestAdapter" Version="1.3.2" />
<PackageReference Include="MSTest.TestFramework" Version="1.3.2" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Threading;
Expand All @@ -9,10 +10,12 @@
using EmailSkill.Dialogs.Shared.Resources;
using EmailSkill.Dialogs.Shared.Resources.Cards;
using EmailSkill.Dialogs.Shared.Resources.Strings;
using EmailSkill.Extensions;
using EmailSkill.ServiceClients;
using EmailSkill.Util;
using Microsoft.Bot.Builder;
using Microsoft.Bot.Builder.Dialogs;
using Microsoft.Bot.Builder.Solutions.Resources;
using Microsoft.Bot.Builder.Solutions.Responses;
using Microsoft.Bot.Builder.Solutions.Skills;
using Microsoft.Bot.Builder.Solutions.Util;
Expand Down Expand Up @@ -71,27 +74,38 @@ public DeleteEmailDialog(
var state = await EmailStateAccessor.GetAsync(sc.Context);
var skillOptions = (EmailSkillDialogOptions)sc.Options;

var focusedMessage = state.Message?.FirstOrDefault();
if (focusedMessage != null)
var message = state.Message?.FirstOrDefault();
if (message != null)
{
var nameListString = DisplayHelper.ToDisplayRecipientsString_Summay(focusedMessage.ToRecipients);
var nameListString = DisplayHelper.ToDisplayRecipientsString_Summay(message.ToRecipients);
var senderIcon = await GetUserPhotoUrlAsync(sc.Context, message.Sender.EmailAddress);
var emailCard = new EmailCardData
{
Subject = string.Format(EmailCommonStrings.SubjectFormat, focusedMessage.Subject),
NameList = string.Format(EmailCommonStrings.ToFormat, nameListString),
EmailContent = string.Format(EmailCommonStrings.ContentFormat, focusedMessage.BodyPreview),
Subject = message.Subject,
EmailContent = message.BodyPreview,
Sender = message.Sender.EmailAddress.Name,
EmailLink = message.WebLink,
ReceivedDateTime = message?.ReceivedDateTime == null
? CommonStrings.NotAvailable
: message.ReceivedDateTime.Value.UtcDateTime.ToDetailRelativeString(state.GetUserTimeZone()),
Speak = SpeakHelper.ToSpeechEmailDetailOverallString(message, state.GetUserTimeZone()),
SenderIcon = senderIcon
};
emailCard = await ProcessRecipientPhotoUrl(sc.Context, emailCard, message.ToRecipients);

var speech = SpeakHelper.ToSpeechEmailSendDetailString(focusedMessage.Subject, nameListString, focusedMessage.BodyPreview);
var speech = SpeakHelper.ToSpeechEmailSendDetailString(message.Subject, nameListString, message.BodyPreview);
var tokens = new StringDictionary
{
{ "EmailDetails", speech },
};

var recipientCard = message.ToRecipients.Count() > 5 ? "DetailCard_RecipientMoreThanFive" : "DetailCard_RecipientLessThanFive";
var prompt = ResponseManager.GetCardResponse(
DeleteEmailResponses.DeleteConfirm,
new Card("EmailWithOutButtonCard", emailCard),
tokens);
new Card("EmailDetailCard", emailCard),
tokens,
"items",
new List<Card>().Append(new Card(recipientCard, emailCard)));

var retry = ResponseManager.GetResponse(EmailSharedResponses.ConfirmSendFailed);

Expand Down
Loading