Skip to content

Commit

Permalink
Copy runtime into new bot projects (#1016)
Browse files Browse the repository at this point in the history
* add deploy scripts

* remove commented line.

* rename the script and add environment.

* add output

* add luis config.

* add custom config from PR #719

* minor fix for comments.

* deploy steps in settings page

* add runtime generate script

* update design of deploy wizard, include realistic commands, copy to clipboard, improvements to nav glow

* add currently open bot projects' path to the state

* remove admin controller for key managment, use script instead.

* add deployment runtime

* use dotnet set user secrets command to set luis key and app password

* add application insights deloyment template.

* add cosmos db deployment

* add error message for deploy script.

* delete scripts in local runtime. only keep scripts in deployment runtime instead.

* add azure storage deployment

* change folder name

* 2 buttons on deploy screen

* 2 buttons on deploy screen

* reset the local runtime.

* remove docker related file for templates.

* change namespace.

* remove auto reloading in template runtime

* add settings check for cosmosdb && azure storage for tranScript

* delete user secret id, change nuget settings.

* remove composerdata folder.

* init user secret.

* include composerdialogs.

* bot path is not necessary.

* remove debugger.

* Adjust new bot creation to include the runtime code
Move dialog content in the templates into a folder called ComposerDialogs/

* update to validation, form values

* sync validators

* gif file

* Add support for copying files from the local folder
rather than some externally specified folder

* add final GIF for deploy

* move generated folder into ComposerDialogs

* Fix case of Scripts folder in deploy instructions

* ensure lu and dialog files end up inside the composerDialogs folder

* add luis feature

* Update template-with-preexisting-rg.json

* complete luis feature.

* make sure bot content is loaded from ComposerDialogs

* use settings from project file to determine luis

* slightly adjust paths

* clean up

* fix path

* fix path

* update assetmanager test to include runtime path

* add empty runtime

* adjust tests to compensate for new folders

* update paths for test settings files

* fix linter error

* update tests
  • Loading branch information
benbrown authored and cwhitten committed Oct 14, 2019
1 parent 06f9771 commit 8a607fe
Show file tree
Hide file tree
Showing 114 changed files with 10,856 additions and 94 deletions.
5 changes: 2 additions & 3 deletions BotProject/CSharp/BotManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
using System.Reflection;
using System.Threading.Tasks;

namespace Microsoft.Bot.Builder.TestBot.Json
namespace Microsoft.Bot.Builder.ComposerBot.json
{
public interface IBotManager
{
Expand Down Expand Up @@ -71,7 +71,6 @@ public void SetCurrent(string botDir)
.UseState(userState, conversationState)
.UseLanguageGeneration(resourceExplorer)
.UseDebugger(4712)
.Use(new RegisterClassMiddleware<IConfiguration>(Config))
.Use(new InspectionMiddleware(inspectionState, userState, conversationState, credentials))
.UseResourceExplorer(resourceExplorer);

Expand All @@ -84,7 +83,7 @@ public void SetCurrent(string botDir)
};
CurrentAdapter = adapter;

CurrentBot = new TestBot("Main.dialog", conversationState, userState, resourceExplorer, DebugSupport.SourceRegistry);
CurrentBot = new ComposerBot("Main.dialog", conversationState, userState, resourceExplorer, DebugSupport.SourceRegistry);
}

public void SetCurrent(Stream fileStream, string endpointKey = null, string appPwd = null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
using Newtonsoft.Json;


namespace Microsoft.Bot.Builder.TestBot.Json
namespace Microsoft.Bot.Builder.ComposerBot.json
{
public class TestBot : ActivityHandler
public class ComposerBot : ActivityHandler
{
private AdaptiveDialog rootDialog;
private readonly ResourceExplorer resourceExplorer;
Expand All @@ -31,7 +31,7 @@ public class TestBot : ActivityHandler
private Source.IRegistry registry;
private string rootDialogFile { get; set; }

public TestBot(string rootDialogFile, ConversationState conversationState, UserState userState, ResourceExplorer resourceExplorer, Source.IRegistry registry)
public ComposerBot(string rootDialogFile, ConversationState conversationState, UserState userState, ResourceExplorer resourceExplorer, Source.IRegistry registry)
{
this.conversationState = conversationState;
this.userState = userState;
Expand Down
2 changes: 0 additions & 2 deletions BotProject/CSharp/ComposerData/README.md

This file was deleted.

2 changes: 1 addition & 1 deletion BotProject/CSharp/Controllers/BotAdminController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace Microsoft.Bot.Builder.TestBot.Json
namespace Microsoft.Bot.Builder.ComposerBot.json
{
[Route("api/admin")]
[ApiController]
Expand Down
2 changes: 1 addition & 1 deletion BotProject/CSharp/Controllers/BotController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
using Microsoft.Bot.Builder.Dialogs.Debugging;
using Microsoft.Bot.Builder.Integration.AspNet.Core;

namespace Microsoft.Bot.Builder.TestBot.Json
namespace Microsoft.Bot.Builder.ComposerBot.json
{
// This ASP Controller is created to handle a request. Dependency Injection will provide the Adapter and IBot
// implementation at runtime. Multiple different IBot implementations running at different endpoints can be
Expand Down
2 changes: 1 addition & 1 deletion BotProject/CSharp/LuisConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.Linq;
using System.Threading.Tasks;

namespace Microsoft.Bot.Builder.TestBot.Json
namespace Microsoft.Bot.Builder.ComposerBot.json
{
public class LuisCustomConfig
{
Expand Down
2 changes: 1 addition & 1 deletion BotProject/CSharp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using System;
using System.IO;

namespace Microsoft.Bot.Builder.TestBot.Json
namespace Microsoft.Bot.Builder.ComposerBot.json
{
public class Program
{
Expand Down
4 changes: 2 additions & 2 deletions BotProject/CSharp/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
"BotProject": {
"commandName": "Project",
"launchBrowser": true,
"applicationUrl": "http://localhost:3979",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "http://localhost:3979"
}
}
}
}
40 changes: 0 additions & 40 deletions BotProject/CSharp/Recognizers/RuleRecognizer.cs

This file was deleted.

2 changes: 1 addition & 1 deletion BotProject/CSharp/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
using Microsoft.Bot.Builder.BotFramework;
using Microsoft.Bot.Builder.Dialogs.Declarative;

namespace Microsoft.Bot.Builder.TestBot.Json
namespace Microsoft.Bot.Builder.ComposerBot.json
{
public class Startup
{
Expand Down
2 changes: 1 addition & 1 deletion BotProject/CSharp/Tests/ActionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using Microsoft.Bot.Builder.Dialogs.Declarative;
using Microsoft.Bot.Builder.Dialogs.Declarative.Resources;
using Microsoft.Bot.Builder.Dialogs.Declarative.Types;
using Microsoft.Bot.Builder.TestBot.Json;
using Microsoft.Bot.Builder.ComposerBot.json;
using Microsoft.Bot.Schema;
using Microsoft.Extensions.Configuration;
using Microsoft.VisualStudio.TestTools.UnitTesting;
Expand Down
2 changes: 1 addition & 1 deletion BotProject/CSharp/Tests/ControllingConversationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using Microsoft.Bot.Builder.Dialogs.Declarative;
using Microsoft.Bot.Builder.Dialogs.Declarative.Resources;
using Microsoft.Bot.Builder.Dialogs.Declarative.Types;
using Microsoft.Bot.Builder.TestBot.Json;
using Microsoft.Bot.Builder.ComposerBot.json;
using Microsoft.Bot.Schema;
using Microsoft.Extensions.Configuration;
using Microsoft.VisualStudio.TestTools.UnitTesting;
Expand Down
2 changes: 1 addition & 1 deletion BotProject/CSharp/Tests/InputsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using Microsoft.Bot.Builder.Dialogs.Declarative;
using Microsoft.Bot.Builder.Dialogs.Declarative.Resources;
using Microsoft.Bot.Builder.Dialogs.Declarative.Types;
using Microsoft.Bot.Builder.TestBot.Json;
using Microsoft.Bot.Builder.ComposerBot.json;
using Microsoft.Bot.Schema;
using Microsoft.Extensions.Configuration;
using Microsoft.VisualStudio.TestTools.UnitTesting;
Expand Down
2 changes: 1 addition & 1 deletion BotProject/CSharp/Tests/MessageTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using Microsoft.Bot.Builder.Dialogs.Declarative;
using Microsoft.Bot.Builder.Dialogs.Declarative.Resources;
using Microsoft.Bot.Builder.Dialogs.Declarative.Types;
using Microsoft.Bot.Builder.TestBot.Json;
using Microsoft.Bot.Builder.ComposerBot.json;
using Microsoft.Bot.Schema;
using Microsoft.Extensions.Configuration;
using Microsoft.VisualStudio.TestTools.UnitTesting;
Expand Down
2 changes: 1 addition & 1 deletion BotProject/CSharp/Tests/ToDoBotTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using Microsoft.Bot.Builder.Dialogs.Declarative;
using Microsoft.Bot.Builder.Dialogs.Declarative.Resources;
using Microsoft.Bot.Builder.Dialogs.Declarative.Types;
using Microsoft.Bot.Builder.TestBot.Json;
using Microsoft.Bot.Builder.ComposerBot.json;
using Microsoft.Bot.Schema;
using Microsoft.Extensions.Configuration;
using Microsoft.VisualStudio.TestTools.UnitTesting;
Expand Down
9 changes: 9 additions & 0 deletions BotProject/Templates/CSharp/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/

!Properties/launchSettings.json
!packages/packages.json
33 changes: 33 additions & 0 deletions BotProject/Templates/CSharp/BotProject.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Compile Remove="Tests\**" />
<Content Remove="Tests\**" />
<EmbeddedResource Remove="Tests\**" />
<None Remove="Tests\**" />
</ItemGroup>
<ItemGroup>
<None Include="ComposerDialogs\**">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.1.1" />
<PackageReference Include="Microsoft.Bot.Builder" Version="4.6.0-Daily-2019-08-31-01" />
<PackageReference Include="Microsoft.Bot.Builder.ApplicationInsights" Version="4.6.0-Daily-2019-08-31-01" />
<PackageReference Include="Microsoft.Bot.Builder.Azure" Version="4.6.0-Daily-2019-08-31-01" />
<PackageReference Include="Microsoft.Bot.Builder.Dialogs.Adaptive" Version="4.6.0-Daily-2019-08-31-01" />
<PackageReference Include="Microsoft.Bot.Builder.Dialogs.Debugging" Version="4.6.0-Daily-2019-08-31-01" />
<PackageReference Include="Microsoft.Bot.Builder.Dialogs.Declarative" Version="4.6.0-Daily-2019-08-31-01" />
<PackageReference Include="Microsoft.Bot.Builder.Integration.ApplicationInsights.Core" Version="4.6.0-Daily-2019-08-31-01" />
<PackageReference Include="Microsoft.Bot.Builder.Integration.AspNet.Core" Version="4.6.0-Daily-2019-08-31-01" />
<PackageReference Include="Microsoft.Bot.Builder.LanguageGeneration.Renderer" Version="4.6.0-Daily-2019-08-31-01" />
<PackageReference Include="Microsoft.Bot.Connector" Version="4.6.0-Daily-2019-08-31-01" />
<PackageReference Include="MSTest.TestFramework" Version="1.4.0" />
</ItemGroup>
<ItemGroup>
<Folder Include="ComposerDialogs\" />
</ItemGroup>
</Project>
31 changes: 31 additions & 0 deletions BotProject/Templates/CSharp/BotProject.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28307.136
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BotProject", "BotProject.csproj", "{80ACF5BE-4A04-46F8-A83E-530FB21948D5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "Tests\Tests.csproj", "{5AFADEA2-A18F-46DF-8080-2CA418880318}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{80ACF5BE-4A04-46F8-A83E-530FB21948D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{80ACF5BE-4A04-46F8-A83E-530FB21948D5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{80ACF5BE-4A04-46F8-A83E-530FB21948D5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{80ACF5BE-4A04-46F8-A83E-530FB21948D5}.Release|Any CPU.Build.0 = Release|Any CPU
{5AFADEA2-A18F-46DF-8080-2CA418880318}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5AFADEA2-A18F-46DF-8080-2CA418880318}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5AFADEA2-A18F-46DF-8080-2CA418880318}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5AFADEA2-A18F-46DF-8080-2CA418880318}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B13FC467-1A63-4C8F-A29E-43B2D8B79B17}
EndGlobalSection
EndGlobal
38 changes: 38 additions & 0 deletions BotProject/Templates/CSharp/BotSettings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using Microsoft.ApplicationInsights.Extensibility;
using Microsoft.Bot.Builder.Azure;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Microsoft.Bot.Builder.ComposerBot.json
{
public class BotSettings
{
public BotSettings()
{

}

public BlobStorageConfiguration BlobStorage { get; set; }

public string MicrosoftAppId { get; set; }

public string MicrosoftAppPassword { get; set; }

public CosmosDbStorageOptions CosmosDb { get; set; }

public TelemetryConfiguration AppInsights { get; set; }

public class BlobStorageConfiguration
{
public BlobStorageConfiguration()
{

}

public string ConnectionString { get; set; }
public string Container { get; set; }
}
}
}
63 changes: 63 additions & 0 deletions BotProject/Templates/CSharp/ComposerBot.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Bot.Builder.Dialogs;
using Microsoft.Bot.Builder.Dialogs.Adaptive;
using Microsoft.Bot.Builder.Dialogs.Debugging;
using Microsoft.Bot.Builder.Dialogs.Declarative;
using Microsoft.Bot.Builder.Dialogs.Declarative.Resources;
using Microsoft.Bot.Schema;
using Microsoft.Extensions.Configuration;
using Microsoft.Recognizers.Text;
using Newtonsoft.Json;


namespace Microsoft.Bot.Builder.ComposerBot.json
{
public class ComposerBot : ActivityHandler
{
private AdaptiveDialog rootDialog;
private readonly ResourceExplorer resourceExplorer;
private UserState userState;
private DialogManager dialogManager;
private ConversationState conversationState;
private IStatePropertyAccessor<DialogState> dialogState;
private Source.IRegistry registry;
private string rootDialogFile { get; set; }
private IBotTelemetryClient telemetryClient;

public ComposerBot(string rootDialogFile, ConversationState conversationState, UserState userState, ResourceExplorer resourceExplorer, Source.IRegistry registry, IBotTelemetryClient telemetryClient)
{
this.conversationState = conversationState;
this.userState = userState;
this.dialogState = conversationState.CreateProperty<DialogState>("DialogState");
this.registry = registry;
this.resourceExplorer = resourceExplorer;
this.rootDialogFile = rootDialogFile;
this.telemetryClient = telemetryClient;

LoadRootDialogAsync();
}

private void LoadRootDialogAsync()
{
var rootFile = resourceExplorer.GetResource(rootDialogFile);
rootDialog = DeclarativeTypeLoader.Load<AdaptiveDialog>(rootFile, resourceExplorer, registry);
this.dialogManager = new DialogManager(rootDialog);
}

public override async Task OnTurnAsync(ITurnContext turnContext, CancellationToken cancellationToken = default(CancellationToken))
{
this.telemetryClient.TrackTrace("Activity:" + turnContext.Activity.Text, Severity.Information, null);
await this.dialogManager.OnTurnAsync(turnContext, cancellationToken: cancellationToken);
await this.conversationState.SaveChangesAsync(turnContext, false, cancellationToken);
await this.userState.SaveChangesAsync(turnContext, false, cancellationToken);
}
}
}
Loading

0 comments on commit 8a607fe

Please sign in to comment.