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] Updated todo skill to new folder structure + config (#1051)
* cleanup * to do skill refactor * updates to todo skill folder structure + new config * updates to VA template * removed old deployment files * fixed merge issues * updated mbbs version
- Loading branch information
1 parent
ecccfe2
commit ebb536b
Showing
124 changed files
with
971 additions
and
4,203 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
44 changes: 44 additions & 0 deletions
44
solutions/Virtual-Assistant/src/csharp/skills/todoskill/todoskill/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,44 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using System.Globalization; | ||
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; | ||
using ToDoSkill.Responses.Shared; | ||
using ToDoSkill.Services; | ||
|
||
namespace ToDoSkill.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(ToDoSharedResponses.ToDoErrorMessage)); | ||
await context.SendActivityAsync(new Activity(type: ActivityTypes.Trace, text: $"To Do 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)); | ||
} | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
...ions/Virtual-Assistant/src/csharp/skills/todoskill/todoskill/Adapters/ToDoSkillAdapter.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,42 @@ | ||
using System.Globalization; | ||
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; | ||
using ToDoSkill.Responses.Shared; | ||
using ToDoSkill.Services; | ||
|
||
namespace ToDoSkill.Adapters | ||
{ | ||
public class ToDoSkillAdapter : SkillAdapter | ||
{ | ||
public ToDoSkillAdapter( | ||
BotSettings settings, | ||
ICredentialProvider credentialProvider, | ||
UserState userState, | ||
ConversationState conversationState, | ||
ResponseManager responseManager, | ||
IBotTelemetryClient telemetryClient) | ||
: base(credentialProvider) | ||
{ | ||
OnTurnError = async (context, exception) => | ||
{ | ||
CultureInfo.CurrentUICulture = new CultureInfo(context.Activity.Locale); | ||
await context.SendActivityAsync(responseManager.GetResponse(ToDoSharedResponses.ToDoErrorMessage)); | ||
await context.SendActivityAsync(new Activity(type: ActivityTypes.Trace, text: $"To Do 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(userState, conversationState)); | ||
} | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
solutions/Virtual-Assistant/src/csharp/skills/todoskill/todoskill/Bots/DefaultBot.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,55 @@ | ||
// 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; | ||
using ToDoSkill.Dialogs; | ||
using ToDoSkill.Services; | ||
|
||
namespace ToDoSkill | ||
{ | ||
public class DefaultBot<T> : ActivityHandler | ||
where T : Dialog | ||
{ | ||
private readonly IBotTelemetryClient _telemetryClient; | ||
private DialogSet _dialogs; | ||
|
||
public DefaultBot(IServiceProvider serviceProvider, T dialog) | ||
{ | ||
var services = serviceProvider.GetService<BotServices>() ?? throw new ArgumentNullException(nameof(BotServices)); | ||
var conversationState = serviceProvider.GetService<ConversationState>() ?? throw new ArgumentNullException(nameof(ConversationState)); | ||
var userState = serviceProvider.GetService<UserState>() ?? throw new ArgumentNullException(nameof(UserState)); | ||
_telemetryClient = serviceProvider.GetService<IBotTelemetryClient>() ?? throw new ArgumentNullException(nameof(IBotTelemetryClient)); | ||
|
||
var dialogState = conversationState.CreateProperty<DialogState>(nameof(ToDoSkill)); | ||
_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.