Skip to content

Commit

Permalink
Replicate changes to templates of C# and TypeScript
Browse files Browse the repository at this point in the history
  • Loading branch information
Batta32 committed Jun 9, 2021
1 parent 22dd469 commit 707281f
Show file tree
Hide file tree
Showing 20 changed files with 66 additions and 257 deletions.
2 changes: 1 addition & 1 deletion templates/csharp/Skill/Skill/Adapters/DefaultAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public DefaultAdapter(
Use(new ShowTypingMiddleware());
Use(new SetLocaleMiddleware(settings.DefaultLocale ?? "en-us"));
Use(new EventDebuggerMiddleware());
Use(new SetSpeakMiddleware());
Use(new SetSpeakMiddleware("en-US-JennyNeural", true));
}

private async Task HandleTurnErrorAsync(ITurnContext turnContext, Exception exception)
Expand Down

This file was deleted.

14 changes: 7 additions & 7 deletions templates/csharp/Skill/Skill/Skill.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.0" />
<PackageReference Include="Microsoft.Azure.CognitiveServices.ContentModerator" Version="2.0.0" />
<PackageReference Include="Microsoft.Azure.CognitiveServices.Language" Version="1.0.1-preview" />
<PackageReference Include="Microsoft.Bot.Builder.AI.Luis" Version="4.9.3" />
<PackageReference Include="Microsoft.Bot.Builder.AI.QnA" Version="4.9.3" />
<PackageReference Include="Microsoft.Bot.Builder.ApplicationInsights" Version="4.9.3" />
<PackageReference Include="Microsoft.Bot.Builder.Azure" Version="4.9.3" />
<PackageReference Include="Microsoft.Bot.Builder.Integration.ApplicationInsights.Core" Version="4.9.3" />
<PackageReference Include="Microsoft.Bot.Builder.Integration.AspNet.Core" Version="4.9.3" />
<PackageReference Include="Microsoft.Bot.Solutions" Version="1.0.1" />
<PackageReference Include="Microsoft.Bot.Builder.AI.Luis" Version="4.13.2" />
<PackageReference Include="Microsoft.Bot.Builder.AI.QnA" Version="4.13.2" />
<PackageReference Include="Microsoft.Bot.Builder.ApplicationInsights" Version="4.13.2" />
<PackageReference Include="Microsoft.Bot.Builder.Azure.Blobs" Version="4.13.2" />
<PackageReference Include="Microsoft.Bot.Builder.Integration.ApplicationInsights.Core" Version="4.13.2" />
<PackageReference Include="Microsoft.Bot.Builder.Integration.AspNet.Core" Version="4.13.2" />
<PackageReference Include="Microsoft.Bot.Solutions" Version="1.1.0" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 4 additions & 2 deletions templates/csharp/Skill/Skill/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using $safeprojectname$.Adapters;
using $safeprojectname$.Authentication;
using $safeprojectname$.Bots;
using $safeprojectname$.Dialogs;
using $safeprojectname$.Services;
Expand Down Expand Up @@ -72,7 +71,10 @@ public void ConfigureServices(IServiceCollection services)
services.AddSingleton<IChannelProvider, ConfigurationChannelProvider>();

// Register AuthConfiguration to enable custom claim validation.
services.AddSingleton(sp => new AuthenticationConfiguration { ClaimsValidator = new AllowedCallersClaimsValidator(sp.GetService<IConfiguration>()) });
services.AddSingleton(sp => new AuthenticationConfiguration
{
ClaimsValidator = new AllowedCallersClaimsValidator(sp.GetService<IConfiguration>().GetSection("allowedCallers").Get<List<string>>())
});

// Configure configuration provider
services.AddSingleton<ICredentialProvider, ConfigurationCredentialProvider>();
Expand Down
2 changes: 1 addition & 1 deletion templates/csharp/VA/VA/Adapters/DefaultAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public DefaultAdapter(
Use(new ShowTypingMiddleware());
Use(new SetLocaleMiddleware(settings.DefaultLocale ?? "en-us"));
Use(new EventDebuggerMiddleware());
Use(new SetSpeakMiddleware());
Use(new SetSpeakMiddleware("en-US-JennyNeural", true));
}

private async Task HandleTurnErrorAsync(ITurnContext turnContext, Exception exception)
Expand Down

This file was deleted.

5 changes: 3 additions & 2 deletions templates/csharp/VA/VA/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Microsoft.ApplicationInsights.Extensibility;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
Expand All @@ -24,7 +25,6 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using $safeprojectname$.Adapters;
using $safeprojectname$.Authentication;
using $safeprojectname$.Bots;
using $safeprojectname$.Dialogs;
using $safeprojectname$.Services;
Expand Down Expand Up @@ -73,7 +73,8 @@ public void ConfigureServices(IServiceCollection services)
services.AddSingleton(skillsConfig);

// Register AuthConfiguration to enable custom claim validation.
services.AddSingleton(sp => new AuthenticationConfiguration { ClaimsValidator = new AllowedCallersClaimsValidator(skillsConfig) });
var allowedCallers = (from skill in skillsConfig.Skills.Values select skill.AppId).ToList();
services.AddSingleton(sp => new AuthenticationConfiguration { ClaimsValidator = new AllowedCallersClaimsValidator(allowedCallers) });

// Configure telemetry
services.AddApplicationInsightsTelemetry();
Expand Down
16 changes: 8 additions & 8 deletions templates/csharp/VA/VA/VA.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.0" />
<PackageReference Include="Microsoft.Azure.CognitiveServices.ContentModerator" Version="2.0.0" />
<PackageReference Include="Microsoft.Azure.CognitiveServices.Language" Version="1.0.1-preview" />
<PackageReference Include="Microsoft.Bot.Builder.AI.Luis" Version="4.9.3" />
<PackageReference Include="Microsoft.Bot.Builder.AI.QnA" Version="4.9.3" />
<PackageReference Include="Microsoft.Bot.Builder.ApplicationInsights" Version="4.9.3" />
<PackageReference Include="Microsoft.Bot.Builder.Azure" Version="4.9.3" />
<PackageReference Include="Microsoft.Bot.Builder.Integration.ApplicationInsights.Core" Version="4.9.3" />
<PackageReference Include="Microsoft.Bot.Builder.Integration.AspNet.Core" Version="4.9.3" />
<PackageReference Include="Microsoft.Bot.Builder.LanguageGeneration" Version="4.9.3" />
<PackageReference Include="Microsoft.Bot.Solutions" Version="1.0.1" />
<PackageReference Include="Microsoft.Bot.Builder.AI.Luis" Version="4.13.2" />
<PackageReference Include="Microsoft.Bot.Builder.AI.QnA" Version="4.13.2" />
<PackageReference Include="Microsoft.Bot.Builder.ApplicationInsights" Version="4.13.2" />
<PackageReference Include="Microsoft.Bot.Builder.Azure" Version="4.13.2" />
<PackageReference Include="Microsoft.Bot.Builder.Integration.ApplicationInsights.Core" Version="4.13.2" />
<PackageReference Include="Microsoft.Bot.Builder.Integration.AspNet.Core" Version="4.13.2" />
<PackageReference Include="Microsoft.Bot.Builder.LanguageGeneration" Version="4.13.2" />
<PackageReference Include="Microsoft.Bot.Solutions" Version="1.1.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,16 @@
"dependencies": {
"@microsoft/microsoft-graph-client": "^1.3.0",
"@microsoft/microsoft-graph-types": "^1.5.0",
"botbuilder": "^4.9.2",
"botbuilder-ai": "^4.9.2",
"botbuilder-applicationinsights": "^4.9.2",
"botbuilder-azure": "^4.9.2",
"botbuilder-dialogs": "^4.9.2",
"botbuilder-lg": "^4.9.2",
"bot-solutions": "^1.0.0",
"botframework-config": "^4.9.2",
"botframework-connector": "^4.9.2",
"botbuilder": "^4.13.5",
"botbuilder-ai": "^4.13.5",
"botbuilder-applicationinsights": "^4.13.5",
"botbuilder-azure": "^4.13.5",
"botbuilder-azure-blobs": "^4.13.5-preview",
"botbuilder-dialogs": "^4.13.5",
"botbuilder-lg": "^4.13.5",
"bot-solutions": "^1.1.0",
"botframework-config": "^4.13.5-deprecated",
"botframework-connector": "^4.13.5",
"restify": "^8.5.1"
},
"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ import {
BotFrameworkAdapterSettings,
BotTelemetryClient,
ConversationState,
SetSpeakMiddleware,
ShowTypingMiddleware,
SkillHttpClient,
TranscriptLoggerMiddleware,
TranscriptStore,
TurnContext,
TelemetryException } from 'botbuilder';
import { AzureBlobTranscriptStore } from 'botbuilder-azure';
import { BlobsTranscriptStore } from 'botbuilder-azure-blobs';
import {
EventDebuggerMiddleware,
LocaleTemplateManager,
SetLocaleMiddleware,
SetSpeakMiddleware } from 'bot-solutions';
SetLocaleMiddleware } from 'bot-solutions';
import { TelemetryInitializerMiddleware } from 'botbuilder-applicationinsights';
import { IBotSettings } from '../services/botSettings.js';
import { ActivityEx, SkillsConfiguration } from 'bot-solutions/lib';
Expand Down Expand Up @@ -67,10 +67,7 @@ export class DefaultAdapter extends BotFrameworkAdapter {
throw new Error('There is no blobStorage value in appsettings file');
}

const transcriptStore: TranscriptStore = new AzureBlobTranscriptStore({
containerName: settings.blobStorage.container,
storageAccountOrConnectionString: settings.blobStorage.connectionString
});
const transcriptStore: TranscriptStore = new BlobsTranscriptStore(settings.blobStorage.connectionString, settings.blobStorage.container);

this.use(telemetryMiddleware);

Expand All @@ -80,7 +77,7 @@ export class DefaultAdapter extends BotFrameworkAdapter {
this.use(new ShowTypingMiddleware());
this.use(new SetLocaleMiddleware(settings.defaultLocale || 'en-us'));
this.use(new EventDebuggerMiddleware());
this.use(new SetSpeakMiddleware());
this.use(new SetSpeakMiddleware('en-US-JennyNeural', true));
}

private async handleTurnError(turnContext: TurnContext, error: Error): Promise<void> {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
Activity,
ActivityTypes,
BotState,
ChannelAccount,
Channels,
ConversationState,
SigninStateVerificationQuery,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ export class MainDialog extends ComponentDialog {
return await stepContext.beginDialog(dialogId);
} else if (this.shouldBeginChitChatDialog(stepContext, dispatchIntent, dispatchScore)) {
DialogContextEx.suppressCompletionMessage(stepContext, true);
const dialogId = this.registerLocalizedQnADialog('chitchat', stepContext.context, localizedServices)
const dialogId = this.registerLocalizedQnADialog('chitchat', stepContext.context, localizedServices);

return await stepContext.beginDialog(dialogId);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,19 @@ import {
UserState,
TelemetryLoggerMiddleware,
SkillHttpClient,
SkillConversationIdFactory,
BotFrameworkSkill } from 'botbuilder';
import { ApplicationInsightsTelemetryClient, ApplicationInsightsWebserverMiddleware } from 'botbuilder-applicationinsights';
import { CosmosDbPartitionedStorage, CosmosDbPartitionedStorageOptions } from 'botbuilder-azure';
import { CosmosDbPartitionedStorage } from 'botbuilder-azure';
import { Dialog, SkillDialog, SkillDialogOptions } from 'botbuilder-dialogs';
import {
CognitiveModelConfiguration,
CosmosDbPartitionedStorageOptions,
LocaleTemplateManager,
SwitchSkillDialog,
IEnhancedBotFrameworkSkill,
SkillsConfiguration,
SkillConversationIdFactory } from 'bot-solutions';
import { SimpleCredentialProvider, AuthenticationConfiguration, Claim } from 'botframework-connector';
SkillsConfiguration } from 'bot-solutions';
import { SimpleCredentialProvider, AuthenticationConfiguration, allowedCallersClaimsValidator } from 'botframework-connector';
import { join } from 'path';
import * as restify from 'restify';
import { DefaultAdapter } from './adapters/defaultAdapter';
Expand All @@ -39,7 +40,6 @@ import { IBotSettings } from './services/botSettings';
import { Activity } from 'botframework-schema';
import { TelemetryInitializerMiddleware } from 'botbuilder-applicationinsights';
import { IUserProfileState } from './models/userProfileState';
import { AllowedCallersClaimsValidator } from './authentication/allowedCallersClaimsValidator';
import { ITokenExchangeConfig, TokenExchangeSkillHandler } from './tokenExchange';

function getTelemetryClient(settings: Partial<IBotSettings>): BotTelemetryClient {
Expand Down Expand Up @@ -78,10 +78,10 @@ const credentialProvider: SimpleCredentialProvider = new SimpleCredentialProvide
const skillsConfig: SkillsConfiguration = new SkillsConfiguration(appsettings.botFrameworkSkills as IEnhancedBotFrameworkSkill[], appsettings.skillHostEndpoint);

// Register AuthConfiguration to enable custom claim validation.
const allowedCallersClaimsValidator: AllowedCallersClaimsValidator = new AllowedCallersClaimsValidator(skillsConfig);
const allowedCallers: string[] = [...skillsConfig.skills.values()].map(skill => skill.appId);
const authenticationConfiguration = new AuthenticationConfiguration(
undefined,
(claims: Claim[]) => allowedCallersClaimsValidator.validateClaims(claims)
allowedCallersClaimsValidator(allowedCallers)
);

// Configure telemetry
Expand Down
Loading

0 comments on commit 707281f

Please sign in to comment.