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

Commit

Permalink
[4.4] Email skill folder restructure + config (#1061)
Browse files Browse the repository at this point in the history
* 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
lauren-mills authored and darrenj committed Apr 6, 2019
1 parent 8a2da3f commit 662156f
Show file tree
Hide file tree
Showing 165 changed files with 1,063 additions and 5,154 deletions.
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));
}
}
}
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));
}
}
}
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);
}
}
}
}
Loading

0 comments on commit 662156f

Please sign in to comment.