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

Commit 9df21a7

Browse files
authored
Lamil/eb lu update (#468)
* update language models to latest * updated to template * including chitchat.lu in template * updated sample to latest
1 parent d444d8a commit 9df21a7

File tree

91 files changed

+125856
-6379
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+125856
-6379
lines changed

templates/Enterprise-Template/src/csharp/EnterpriseBotSample/BotServices.cs

Lines changed: 61 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
33

4+
using System;
45
using System.Collections.Generic;
56
using EnterpriseBotSample.Middleware.Telemetry;
67
using Microsoft.ApplicationInsights;
8+
using Microsoft.ApplicationInsights.Extensibility;
79
using Microsoft.Bot.Builder.AI.Luis;
810
using Microsoft.Bot.Builder.AI.QnA;
911
using Microsoft.Bot.Configuration;
@@ -32,14 +34,44 @@ public BotServices(BotConfiguration botConfiguration)
3234
{
3335
case ServiceTypes.AppInsights:
3436
{
35-
var appInsights = service as AppInsightsService;
36-
TelemetryClient = new TelemetryClient();
37+
var appInsights = (AppInsightsService)service;
38+
if (appInsights == null)
39+
{
40+
throw new InvalidOperationException("The Application Insights is not configured correctly in your '.bot' file.");
41+
}
42+
43+
if (string.IsNullOrWhiteSpace(appInsights.InstrumentationKey))
44+
{
45+
throw new InvalidOperationException("The Application Insights Instrumentation Key ('instrumentationKey') is required to run this sample. Please update your '.bot' file.");
46+
}
47+
48+
var telemetryConfig = new TelemetryConfiguration(appInsights.InstrumentationKey);
49+
TelemetryClient = new TelemetryClient(telemetryConfig)
50+
{
51+
InstrumentationKey = appInsights.InstrumentationKey,
52+
};
53+
3754
break;
3855
}
3956

4057
case ServiceTypes.Dispatch:
4158
{
4259
var dispatch = service as DispatchService;
60+
if (dispatch == null)
61+
{
62+
throw new InvalidOperationException("The Dispatch service is not configured correctly in your '.bot' file.");
63+
}
64+
65+
if (string.IsNullOrWhiteSpace(dispatch.AppId))
66+
{
67+
throw new InvalidOperationException("The Dispatch Luis Model Application Id ('appId') is required to run this sample. Please update your '.bot' file.");
68+
}
69+
70+
if (string.IsNullOrWhiteSpace(dispatch.SubscriptionKey))
71+
{
72+
throw new InvalidOperationException("The Subscription Key ('subscriptionKey') is required to run this sample. Please update your '.bot' file.");
73+
}
74+
4375
var dispatchApp = new LuisApplication(dispatch.AppId, dispatch.SubscriptionKey, dispatch.GetEndpoint());
4476
DispatchRecognizer = new TelemetryLuisRecognizer(dispatchApp);
4577
break;
@@ -48,8 +80,34 @@ public BotServices(BotConfiguration botConfiguration)
4880
case ServiceTypes.Luis:
4981
{
5082
var luis = service as LuisService;
83+
if (luis == null)
84+
{
85+
throw new InvalidOperationException("The Luis service is not configured correctly in your '.bot' file.");
86+
}
87+
88+
if (string.IsNullOrWhiteSpace(luis.AppId))
89+
{
90+
throw new InvalidOperationException("The Luis Model Application Id ('appId') is required to run this sample. Please update your '.bot' file.");
91+
}
92+
93+
if (string.IsNullOrWhiteSpace(luis.AuthoringKey))
94+
{
95+
throw new InvalidOperationException("The Luis Authoring Key ('authoringKey') is required to run this sample. Please update your '.bot' file.");
96+
}
97+
98+
if (string.IsNullOrWhiteSpace(luis.SubscriptionKey))
99+
{
100+
throw new InvalidOperationException("The Subscription Key ('subscriptionKey') is required to run this sample. Please update your '.bot' file.");
101+
}
102+
103+
if (string.IsNullOrWhiteSpace(luis.Region))
104+
{
105+
throw new InvalidOperationException("The Region ('region') is required to run this sample. Please update your '.bot' file.");
106+
}
107+
51108
var luisApp = new LuisApplication(luis.AppId, luis.SubscriptionKey, luis.GetEndpoint());
52-
LuisServices.Add(service.Id, new TelemetryLuisRecognizer(luisApp));
109+
var recognizer = new TelemetryLuisRecognizer(luisApp);
110+
LuisServices.Add(service.Id, recognizer);
53111
break;
54112
}
55113

0 commit comments

Comments
 (0)