Skip to content

Commit

Permalink
Merge branch 'master' into UIBug
Browse files Browse the repository at this point in the history
  • Loading branch information
a-b-r-o-w-n authored Apr 20, 2020
2 parents 0004372 + 52548b8 commit ea2fa39
Show file tree
Hide file tree
Showing 314 changed files with 4,687 additions and 4,449 deletions.
20 changes: 10 additions & 10 deletions BotProject/Templates/CSharp/BotProject.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.2" />
<PackageReference Include="Microsoft.Bot.Builder" Version="4.8.0" />
<PackageReference Include="Microsoft.Bot.Builder.ApplicationInsights" Version="4.8.0" />
<PackageReference Include="Microsoft.Bot.Builder.Azure" Version="4.8.0" />
<PackageReference Include="Microsoft.Bot.Builder.Dialogs.Adaptive" Version="4.8.0-rc0" />
<PackageReference Include="Microsoft.Bot.Builder.Dialogs.Debugging" Version="4.8.0-rc0" />
<PackageReference Include="Microsoft.Bot.Builder.Dialogs.Declarative" Version="4.8.0-rc0" />
<PackageReference Include="Microsoft.Bot.Builder.Integration.ApplicationInsights.Core" Version="4.8.0" />
<PackageReference Include="Microsoft.Bot.Builder.Integration.AspNet.Core" Version="4.8.0" />
<PackageReference Include="Microsoft.Bot.Builder.Dialogs" Version="4.8.0" />
<PackageReference Include="Microsoft.Bot.Connector" Version="4.8.0" />
<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="MSTest.TestFramework" Version="1.4.0" />
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.66">
<PrivateAssets>all</PrivateAssets>
Expand Down
24 changes: 20 additions & 4 deletions BotProject/Templates/CSharp/ComposerBot.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System.Security.Claims;
using System.Security.Principal;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Bot.Builder.AI.QnA;
Expand All @@ -10,6 +12,7 @@
using Microsoft.Bot.Builder.Dialogs.Declarative;
using Microsoft.Bot.Builder.Dialogs.Declarative.Resources;
using Microsoft.Bot.Builder.Skills;
using Microsoft.Bot.Connector.Authentication;

namespace Microsoft.Bot.Builder.ComposerBot.Json
{
Expand All @@ -21,8 +24,9 @@ public class ComposerBot : ActivityHandler
private readonly ConversationState conversationState;
private readonly IStatePropertyAccessor<DialogState> dialogState;
private readonly string rootDialogFile;
private readonly string defaultLocale;

public ComposerBot(ConversationState conversationState, UserState userState, ResourceExplorer resourceExplorer, BotFrameworkClient skillClient, SkillConversationIdFactoryBase conversationIdFactory, string rootDialog)
public ComposerBot(ConversationState conversationState, UserState userState, ResourceExplorer resourceExplorer, BotFrameworkClient skillClient, SkillConversationIdFactoryBase conversationIdFactory, string rootDialog, string defaultLocale)
{
HostContext.Current.Set(skillClient);
HostContext.Current.Set(conversationIdFactory);
Expand All @@ -31,11 +35,22 @@ public ComposerBot(ConversationState conversationState, UserState userState, Res
this.dialogState = conversationState.CreateProperty<DialogState>("DialogState");
this.resourceExplorer = resourceExplorer;
this.rootDialogFile = rootDialog;
this.defaultLocale = defaultLocale;
LoadRootDialogAsync();
}

public override async Task OnTurnAsync(ITurnContext turnContext, CancellationToken cancellationToken = default(CancellationToken))
{
AdaptiveDialog rootDialog = (AdaptiveDialog)this.dialogManager.RootDialog;
if (turnContext.TurnState.Get<IIdentity>(BotAdapter.BotIdentityKey) is ClaimsIdentity claimIdentity && SkillValidation.IsSkillClaim(claimIdentity.Claims))
{
rootDialog.AutoEndDialog = true;
}
else
{
rootDialog.AutoEndDialog = false;
}

await this.dialogManager.OnTurnAsync(turnContext, cancellationToken: cancellationToken);
await this.conversationState.SaveChangesAsync(turnContext, false, cancellationToken);
await this.userState.SaveChangesAsync(turnContext, false, cancellationToken);
Expand All @@ -44,10 +59,11 @@ public ComposerBot(ConversationState conversationState, UserState userState, Res
private void LoadRootDialogAsync()
{
var rootFile = resourceExplorer.GetResource(rootDialogFile);
var rootDialog = resourceExplorer.LoadType<Dialog>(rootFile);
var rootDialog = resourceExplorer.LoadType<AdaptiveDialog>(rootFile);
this.dialogManager = new DialogManager(rootDialog)
.UseResourceExplorer(resourceExplorer)
.UseLanguageGeneration();
}
.UseLanguageGeneration()
.UseLanguagePolicy(new LanguagePolicy(defaultLocale));
}
}
}
Loading

0 comments on commit ea2fa39

Please sign in to comment.