This repository has been archived by the owner on Jun 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 529
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[4.4] Email skill folder restructure + config (#1061)
* removed old deployment scripts * email skill started * va template cleanup * more todo cleanup * poi cleanup * todo stylecop * email folder restructure and config
- Loading branch information
1 parent
8a2da3f
commit 662156f
Showing
165 changed files
with
1,063 additions
and
5,154 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
...ions/Virtual-Assistant/src/csharp/skills/emailskill/emailskill/Adapters/DefaultAdapter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using System.Globalization; | ||
using EmailSkill.Responses.Shared; | ||
using EmailSkill.Services; | ||
using Microsoft.Bot.Builder; | ||
using Microsoft.Bot.Builder.Azure; | ||
using Microsoft.Bot.Builder.Integration.AspNet.Core; | ||
using Microsoft.Bot.Builder.Solutions.Middleware; | ||
using Microsoft.Bot.Builder.Solutions.Responses; | ||
using Microsoft.Bot.Builder.Solutions.Telemetry; | ||
using Microsoft.Bot.Connector.Authentication; | ||
using Microsoft.Bot.Schema; | ||
|
||
namespace EmailSkill.Adapters | ||
{ | ||
public class DefaultAdapter : BotFrameworkHttpAdapter | ||
{ | ||
public DefaultAdapter( | ||
BotSettings settings, | ||
ICredentialProvider credentialProvider, | ||
BotStateSet botStateSet, | ||
IBotTelemetryClient telemetryClient, | ||
ResponseManager responseManager) | ||
: base(credentialProvider) | ||
{ | ||
OnTurnError = async (context, exception) => | ||
{ | ||
CultureInfo.CurrentUICulture = new CultureInfo(context.Activity.Locale); | ||
await context.SendActivityAsync(responseManager.GetResponse(EmailSharedResponses.EmailErrorMessage)); | ||
await context.SendActivityAsync(new Activity(type: ActivityTypes.Trace, text: $"Email Skill Error: {exception.Message} | {exception.StackTrace}")); | ||
telemetryClient.TrackExceptionEx(exception, context.Activity); | ||
}; | ||
|
||
Use(new TranscriptLoggerMiddleware(new AzureBlobTranscriptStore(settings.BlobStorage.ConnectionString, settings.BlobStorage.Container))); | ||
Use(new TelemetryLoggerMiddleware(telemetryClient, logPersonalInformation: true)); | ||
Use(new ShowTypingMiddleware()); | ||
Use(new SetLocaleMiddleware(settings.DefaultLocale ?? "en-us")); | ||
Use(new EventDebuggerMiddleware()); | ||
Use(new AutoSaveStateMiddleware(botStateSet)); | ||
} | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
...s/Virtual-Assistant/src/csharp/skills/emailskill/emailskill/Adapters/EmailSkillAdapter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using System.Globalization; | ||
using EmailSkill.Responses.Shared; | ||
using EmailSkill.Services; | ||
using Microsoft.Bot.Builder; | ||
using Microsoft.Bot.Builder.Azure; | ||
using Microsoft.Bot.Builder.Skills; | ||
using Microsoft.Bot.Builder.Solutions.Middleware; | ||
using Microsoft.Bot.Builder.Solutions.Responses; | ||
using Microsoft.Bot.Builder.Solutions.Telemetry; | ||
using Microsoft.Bot.Connector.Authentication; | ||
using Microsoft.Bot.Schema; | ||
|
||
namespace EmailSkill.Adapters | ||
{ | ||
public class EmailSkillAdapter : SkillAdapter | ||
{ | ||
public EmailSkillAdapter( | ||
BotSettings settings, | ||
ICredentialProvider credentialProvider, | ||
BotStateSet botStateSet, | ||
ResponseManager responseManager, | ||
IBotTelemetryClient telemetryClient) | ||
: base(credentialProvider) | ||
{ | ||
OnTurnError = async (context, exception) => | ||
{ | ||
CultureInfo.CurrentUICulture = new CultureInfo(context.Activity.Locale); | ||
await context.SendActivityAsync(responseManager.GetResponse(EmailSharedResponses.EmailErrorMessage)); | ||
await context.SendActivityAsync(new Activity(type: ActivityTypes.Trace, text: $"Email Skill Error: {exception.Message} | {exception.StackTrace}")); | ||
telemetryClient.TrackExceptionEx(exception, context.Activity); | ||
}; | ||
|
||
Use(new TranscriptLoggerMiddleware(new AzureBlobTranscriptStore(settings.BlobStorage.ConnectionString, settings.BlobStorage.Container))); | ||
Use(new TelemetryLoggerMiddleware(telemetryClient, logPersonalInformation: true)); | ||
Use(new ShowTypingMiddleware()); | ||
Use(new SetLocaleMiddleware(settings.DefaultLocale ?? "en-us")); | ||
Use(new EventDebuggerMiddleware()); | ||
Use(new AutoSaveStateMiddleware(botStateSet)); | ||
} | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
solutions/Virtual-Assistant/src/csharp/skills/emailskill/emailskill/Bots/DialogBot.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using System; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Microsoft.Bot.Builder; | ||
using Microsoft.Bot.Builder.Dialogs; | ||
using Microsoft.Bot.Schema; | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
namespace EmailSkill.Bots | ||
{ | ||
public class DialogBot<T> : ActivityHandler | ||
where T : Dialog | ||
{ | ||
private readonly IBotTelemetryClient _telemetryClient; | ||
private DialogSet _dialogs; | ||
|
||
public DialogBot(IServiceProvider serviceProvider, T dialog) | ||
{ | ||
var conversationState = serviceProvider.GetService<ConversationState>() ?? throw new ArgumentNullException(nameof(ConversationState)); | ||
_telemetryClient = serviceProvider.GetService<IBotTelemetryClient>() ?? throw new ArgumentNullException(nameof(IBotTelemetryClient)); | ||
|
||
var dialogState = conversationState.CreateProperty<DialogState>(nameof(EmailSkill)); | ||
_dialogs = new DialogSet(dialogState); | ||
_dialogs.Add(dialog); | ||
} | ||
|
||
public override async Task OnTurnAsync(ITurnContext turnContext, CancellationToken cancellationToken) | ||
{ | ||
// Client notifying this bot took to long to respond (timed out) | ||
if (turnContext.Activity.Code == EndOfConversationCodes.BotTimedOut) | ||
{ | ||
_telemetryClient.TrackTrace($"Timeout in {turnContext.Activity.ChannelId} channel: Bot took too long to respond.", Severity.Information, null); | ||
return; | ||
} | ||
|
||
var dc = await _dialogs.CreateContextAsync(turnContext); | ||
|
||
if (dc.ActiveDialog != null) | ||
{ | ||
var result = await dc.ContinueDialogAsync(); | ||
} | ||
else | ||
{ | ||
await dc.BeginDialogAsync(typeof(T).Name); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.