Skip to content

Commit

Permalink
Merge branch 'master' into julong/keyboardShortCut
Browse files Browse the repository at this point in the history
  • Loading branch information
alanlong9278 committed Apr 28, 2020
2 parents e1b0bfa + ac1e959 commit 24eb763
Show file tree
Hide file tree
Showing 234 changed files with 20,283 additions and 10,822 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

/BotProject/ @boydc2014 @luhan2017

/Composer/ @cwhitten @boydc2014 @a-b-r-o-w-n @corinagum
/Composer/ @cwhitten @boydc2014 @a-b-r-o-w-n @corinagum @beyackle @srinaath

/Composer/packages/extensions/visual-designer @yeze322 @cwhitten @boydc2014 @a-b-r-o-w-n

Expand Down
30 changes: 11 additions & 19 deletions BotProject/Templates/CSharp/BotProject.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
Expand All @@ -9,11 +9,6 @@
<EmbeddedResource Remove="Tests\**" />
<None Remove="Tests\**" />
</ItemGroup>
<ItemGroup>
<None Include="ComposerDialogs\**">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<CodeAnalysisRuleSet>BotProject.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
Expand All @@ -22,23 +17,20 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.2" />
<PackageReference Include="Microsoft.Bot.Builder" Version="4.9.0-preview-200416-120718" />
<PackageReference Include="Microsoft.Bot.Builder.ApplicationInsights" Version="4.9.0-preview-200416-120718" />
<PackageReference Include="Microsoft.Bot.Builder.Azure" Version="4.9.0-preview-200416-120718" />
<PackageReference Include="Microsoft.Bot.Builder.Dialogs.Adaptive" Version="4.9.0-preview-200416-120718" />
<PackageReference Include="Microsoft.Bot.Builder.Dialogs.Debugging" Version="4.9.0-preview-200416-120718" />
<PackageReference Include="Microsoft.Bot.Builder.Dialogs.Declarative" Version="4.9.0-preview-200416-120718" />
<PackageReference Include="Microsoft.Bot.Builder.Integration.ApplicationInsights.Core" Version="4.9.0-preview-200416-120718" />
<PackageReference Include="Microsoft.Bot.Builder.Integration.AspNet.Core" Version="4.9.0-preview-200416-120718" />
<PackageReference Include="Microsoft.Bot.Builder.Dialogs" Version="4.9.0-preview-200416-120718" />
<PackageReference Include="Microsoft.Bot.Connector" Version="4.9.0-preview-200416-120718" />
<PackageReference Include="Microsoft.Bot.Builder" Version="4.9.0-preview.200426-124932" />
<PackageReference Include="Microsoft.Bot.Builder.ApplicationInsights" Version="4.9.0-preview.200426-124932" />
<PackageReference Include="Microsoft.Bot.Builder.Azure" Version="4.9.0-preview.200426-124932" />
<PackageReference Include="Microsoft.Bot.Builder.Dialogs.Adaptive" Version="4.9.0-preview.200426-124932" />
<PackageReference Include="Microsoft.Bot.Builder.Dialogs.Debugging" Version="4.9.0-preview.200426-124932" />
<PackageReference Include="Microsoft.Bot.Builder.Dialogs.Declarative" Version="4.9.0-preview.200426-124932" />
<PackageReference Include="Microsoft.Bot.Builder.Integration.ApplicationInsights.Core" Version="4.9.0-preview.200426-124932" />
<PackageReference Include="Microsoft.Bot.Builder.Integration.AspNet.Core" Version="4.9.0-preview.200426-124932" />
<PackageReference Include="Microsoft.Bot.Builder.Dialogs" Version="4.9.0-preview.200426-124932" />
<PackageReference Include="Microsoft.Bot.Connector" Version="4.9.0-preview.200426-124932" />
<PackageReference Include="MSTest.TestFramework" Version="1.4.0" />
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.66">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<Folder Include="ComposerDialogs\" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Microsoft.Bot.Builder.ComposerBot.Json
{
public class BlobStorageConfiguration
{
public string ConnectionString { get; set; }

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

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Microsoft.Bot.Builder.ComposerBot.Json
{
public class BotFeatureSettings
{
// Use TelementryLoggerMiddleware
public bool UseTelementryLoggerMiddleware { get; set; }

// Use TranscriptLoggerMiddleware
public bool UseTranscriptLoggerMiddleware { get; set; }

// Use ShowTypingMiddleware
public bool UseShowTypingMiddleware { get; set; }

// Use InspectionMiddleware
public bool UseInspectionMiddleware { get; set; }

// Use CosmosDb for storage
public bool UseCosmosDb { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ namespace Microsoft.Bot.Builder.ComposerBot.Json
{
public class BotSettings
{
public BotFeatureSettings Feature { get; set; }

public BlobStorageConfiguration BlobStorage { get; set; }

public string MicrosoftAppId { get; set; }
Expand All @@ -16,13 +18,24 @@ public class BotSettings

public CosmosDbPartitionedStorageOptions CosmosDb { get; set; }

public TelemetryConfiguration AppInsights { get; set; }
public TelemetryConfiguration ApplicationInsights { get; set; }

public AdditionalTelemetryConfiguration Telemetry { get; set; }

public string Bot { get; set; }

public class BlobStorageConfiguration
{
public string ConnectionString { get; set; }

public string Container { get; set; }
}

public class AdditionalTelemetryConfiguration
{
public bool LogPersonalInformation { get; set; }

public bool LogActivities { get; set; }
}
}
}
7 changes: 5 additions & 2 deletions BotProject/Templates/CSharp/ComposerBot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using System.Security.Principal;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Bot.Builder.AI.QnA;
using Microsoft.Bot.Builder.Dialogs;
using Microsoft.Bot.Builder.Dialogs.Adaptive;
using Microsoft.Bot.Builder.Dialogs.Debugging;
Expand All @@ -24,9 +23,10 @@ public class ComposerBot : ActivityHandler
private readonly ConversationState conversationState;
private readonly IStatePropertyAccessor<DialogState> dialogState;
private readonly string rootDialogFile;
private readonly IBotTelemetryClient telemetryClient;
private readonly string defaultLocale;

public ComposerBot(ConversationState conversationState, UserState userState, ResourceExplorer resourceExplorer, BotFrameworkClient skillClient, SkillConversationIdFactoryBase conversationIdFactory, string rootDialog, string defaultLocale)
public ComposerBot(ConversationState conversationState, UserState userState, ResourceExplorer resourceExplorer, BotFrameworkClient skillClient, SkillConversationIdFactoryBase conversationIdFactory, IBotTelemetryClient telemetryClient, string rootDialog, string defaultLocale)
{
HostContext.Current.Set(skillClient);
HostContext.Current.Set(conversationIdFactory);
Expand All @@ -36,6 +36,8 @@ public ComposerBot(ConversationState conversationState, UserState userState, Res
this.resourceExplorer = resourceExplorer;
this.rootDialogFile = rootDialog;
this.defaultLocale = defaultLocale;
this.telemetryClient = telemetryClient;

LoadRootDialogAsync();
}

Expand Down Expand Up @@ -63,6 +65,7 @@ private void LoadRootDialogAsync()
this.dialogManager = new DialogManager(rootDialog)
.UseResourceExplorer(resourceExplorer)
.UseLanguageGeneration()
.UseTelemetry(this.telemetryClient)
.UseLanguagePolicy(new LanguagePolicy(defaultLocale));
}
}
Expand Down
25 changes: 15 additions & 10 deletions BotProject/Templates/CSharp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,32 @@ public static IHostBuilder CreateHostBuilder(string[] args) =>
.ConfigureAppConfiguration((hostingContext, builder) =>
{
var env = hostingContext.HostingEnvironment;

builder.AddJsonFile($"ComposerDialogs/settings/appsettings.json", optional: true, reloadOnChange: true)
.AddJsonFile("appsetting.json", optional: true, reloadOnChange: true)
.UseLuisConfigAdaptor()
.UseLuisSettings();

builder.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);

if (env.IsDevelopment())
{
// Local Debug
builder.AddJsonFile("appsettings.development.json", optional: true, reloadOnChange: true);
}
else

var configuration = builder.Build();

// Hard code the settings path to 'ComposerDialogs' while deployment
var botRoot = configuration.GetValue<string>("bot") ?? "ComposerDialogs";
var configFile = Path.GetFullPath(Path.Combine(botRoot, @"settings/appsettings.json"));

builder.AddJsonFile(configFile, optional: true, reloadOnChange: true);

// Need to put this part here to override the any customized settings
if (!env.IsDevelopment())
{
//Azure Deploy
builder.AddJsonFile("appsettings.deployment.json", optional: true, reloadOnChange: true);
}

if (!env.IsDevelopment())
{
builder.AddUserSecrets<Startup>();
}
builder.UseLuisConfigAdaptor()
.UseLuisSettings();

builder.AddEnvironmentVariables()
.AddCommandLine(args);
Expand Down
36 changes: 29 additions & 7 deletions BotProject/Templates/CSharp/README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,44 @@
## Bot Project
## Bot Runtime
Bot project is the launcher project for the bots written in declarative form (JSON), using the Composer, for the Bot Framework SDK.
This same code is used by Composer to start the bot locally for testing.

## Instructions for setting up the Bot Project runtime
The Bot Project is a regular Bot Framework SDK V4 project. Before you can launch it from the emulator, you need to make sure you can run the bot.
## Instructions for using and customizing the bot runtime

Composer can be configured to use a customized copy of this runtime.
A copy of it can be added to your project automatically by using the "runtime settings" page in Composer.

The Bot Project is a regular Bot Framework SDK V4 project. You can modify the code of this project
and continue to use it with Composer.

* Add additional middleware
* Customize the state storage system
* Add custom dialog classes

### Prerequisite:
* Install .Netcore 3.1

### Commands:
### Build:

* from root folder
* cd BotProject
* cd Templates/CSharp
* cd [my bot folder]/runtime
* dotnet user-secrets init // init the user secret id
* dotnet build // build


### Run from Command line:
* cd [my bot folder]/runtime
* dotnet run // start the bot
* It will start a web server and listening at http://localhost:3979.

### Run with Composer

Open your bot project in Composer. Navigate to the runtime settings tab.

Set the path to runtime to the full path to your runtime code. Customize the start command as necessary.

The "Start Bot" button will now use your customized runtime.

Note: the application code must be built and ready to run before Composer can manage it.

### Test bot
* You can set you emulator to connect to http://localhost:3979/api/messages.

18 changes: 18 additions & 0 deletions BotProject/Templates/CSharp/Schemas/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# How to update the schema file

## To point npm to nightly builds
```
npm config set registry https://botbuilder.myget.org/F/botframework-cli/npm/
```
## To install BF tool:
```
npm i -g @microsoft/botframework-cli
```
## To install bf dialog plugin
```
bf plugins:install @microsoft/bf-dialog
```
## To update your application schema for your bot project
```
update.cmd
```
Loading

0 comments on commit 24eb763

Please sign in to comment.