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

Commit

Permalink
[4.4] Updated todo skill to new folder structure + config (#1051)
Browse files Browse the repository at this point in the history
* 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
lauren-mills authored Apr 4, 2019
1 parent ecccfe2 commit ebb536b
Show file tree
Hide file tree
Showing 124 changed files with 971 additions and 4,203 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -352,4 +352,5 @@ ASALocalRun/
**/Deployment/Resources/Dispatch/**
**/Deployment/appsettings.json
**/Deployment/cognitivemodels.json
**/Deployment/skills.json
**/Deployment/skills.json
/templates/Virtual-Assistant-Template/VirtualAssistantTemplate/Deployment/Scripts/va_add_skill.1.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Bot.Builder.Solutions" Version="4.4.0-preview-9" />
<PackageReference Include="Microsoft.Bot.Builder.Solutions" Version="4.4.34-preview" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<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
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-9" />
<PackageReference Include="Microsoft.Bot.Builder.Solutions" Version="4.4.34-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-9" />
<PackageReference Include="Microsoft.Bot.Builder.Solutions" Version="4.4.34-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-9" />
<PackageReference Include="Microsoft.Bot.Builder.Solutions" Version="4.4.34-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 @@ -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-9" />
<PackageReference Include="Microsoft.Bot.Builder.Solutions" Version="4.4.34-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 @@ -22,7 +22,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-9" />
<PackageReference Include="Microsoft.Bot.Builder.Solutions" Version="4.4.34-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 @@ -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-9" />
<PackageReference Include="Microsoft.Bot.Builder.Solutions" Version="4.4.34-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
@@ -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));
}
}
}
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));
}
}
}
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);
}
}
}
}
Loading

0 comments on commit ebb536b

Please sign in to comment.