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

Commit 801091b

Browse files
authored
Added telemetry client to LUIS and QnA recognizer for logging (#1354)
1 parent 2354824 commit 801091b

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed

templates/Virtual-Assistant-Template/csharp/Sample/VirtualAssistantSample/Services/BotServices.cs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
// Licensed under the MIT License.
33

44
using System.Collections.Generic;
5+
using Microsoft.ApplicationInsights;
56
using Microsoft.Bot.Builder.AI.Luis;
67
using Microsoft.Bot.Builder.AI.QnA;
8+
using Microsoft.Bot.Builder.ApplicationInsights;
79
using Microsoft.Bot.Builder.Solutions;
810

911
namespace VirtualAssistantSample.Services
@@ -22,15 +24,23 @@ public BotServices(BotSettings settings)
2224
var language = pair.Key;
2325
var config = pair.Value;
2426

27+
var telemetryClient = new BotTelemetryClient(new TelemetryClient(settings.AppInsights));
28+
var luisOptions = new LuisPredictionOptions()
29+
{
30+
TelemetryClient = telemetryClient,
31+
LogPersonalInformation = true,
32+
};
33+
2534
var dispatchApp = new LuisApplication(config.DispatchModel.AppId, config.DispatchModel.SubscriptionKey, config.DispatchModel.GetEndpoint());
26-
set.DispatchService = new LuisRecognizer(dispatchApp);
35+
36+
set.DispatchService = new LuisRecognizer(dispatchApp, luisOptions);
2737

2838
if (config.LanguageModels != null)
2939
{
3040
foreach (var model in config.LanguageModels)
3141
{
3242
var luisApp = new LuisApplication(model.AppId, model.SubscriptionKey, model.GetEndpoint());
33-
set.LuisServices.Add(model.Id, new LuisRecognizer(luisApp));
43+
set.LuisServices.Add(model.Id, new LuisRecognizer(luisApp, luisOptions));
3444
}
3545
}
3646

@@ -42,7 +52,8 @@ public BotServices(BotSettings settings)
4252
EndpointKey = kb.EndpointKey,
4353
Host = kb.Hostname,
4454
};
45-
var qnaMaker = new QnAMaker(qnaEndpoint);
55+
56+
var qnaMaker = new QnAMaker(qnaEndpoint, null, null, telemetryClient: telemetryClient, logPersonalInformation: true);
4657
set.QnAServices.Add(kb.Id, qnaMaker);
4758
}
4859

templates/Virtual-Assistant-Template/csharp/Template/VA/Services/BotServices.cs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
// Licensed under the MIT License.
33

44
using System.Collections.Generic;
5+
using Microsoft.ApplicationInsights;
56
using Microsoft.Bot.Builder.AI.Luis;
67
using Microsoft.Bot.Builder.AI.QnA;
8+
using Microsoft.Bot.Builder.ApplicationInsights;
79
using Microsoft.Bot.Builder.Solutions;
810

911
namespace $safeprojectname$.Services
@@ -22,15 +24,23 @@ public BotServices(BotSettings settings)
2224
var language = pair.Key;
2325
var config = pair.Value;
2426

27+
var telemetryClient = new BotTelemetryClient(new TelemetryClient(settings.AppInsights));
28+
var luisOptions = new LuisPredictionOptions()
29+
{
30+
TelemetryClient = telemetryClient,
31+
LogPersonalInformation = true,
32+
};
33+
2534
var dispatchApp = new LuisApplication(config.DispatchModel.AppId, config.DispatchModel.SubscriptionKey, config.DispatchModel.GetEndpoint());
26-
set.DispatchService = new LuisRecognizer(dispatchApp);
35+
36+
set.DispatchService = new LuisRecognizer(dispatchApp, luisOptions);
2737

2838
if (config.LanguageModels != null)
2939
{
3040
foreach (var model in config.LanguageModels)
3141
{
3242
var luisApp = new LuisApplication(model.AppId, model.SubscriptionKey, model.GetEndpoint());
33-
set.LuisServices.Add(model.Id, new LuisRecognizer(luisApp));
43+
set.LuisServices.Add(model.Id, new LuisRecognizer(luisApp, luisOptions));
3444
}
3545
}
3646

@@ -42,7 +52,8 @@ public BotServices(BotSettings settings)
4252
EndpointKey = kb.EndpointKey,
4353
Host = kb.Hostname,
4454
};
45-
var qnaMaker = new QnAMaker(qnaEndpoint);
55+
56+
var qnaMaker = new QnAMaker(qnaEndpoint, null, null, telemetryClient: telemetryClient, logPersonalInformation: true);
4657
set.QnAServices.Add(kb.Id, qnaMaker);
4758
}
4859

0 commit comments

Comments
 (0)