forked from amolenk/GameATron4000
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBotServices.cs
55 lines (50 loc) · 1.92 KB
/
BotServices.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using System;
using System.Collections.Generic;
using GameATron4000.Configuration;
using Microsoft.Bot.Builder.AI.Luis;
using Microsoft.Bot.Configuration;
using Microsoft.Extensions.Configuration;
namespace GameATron4000
{
public class BotServices
{
public string BotId { get; private set; }
public string DirectLineSecret { get; private set; }
/// Gets the set of LUIS Services used.
/// LuisServices is represented as a dictionary.
public Dictionary<string, LuisRecognizer> LuisServices { get; } = new Dictionary<string, LuisRecognizer>();
/// Initializes a new instance of the BotServices class
public BotServices(BotConfiguration botConfiguration)
{
foreach (var service in botConfiguration.Services)
{
switch (service.Type)
{
case ServiceTypes.Bot:
{
var botService = (BotService)service;
BotId = botService.ServiceName;
break;
}
case ServiceTypes.Generic:
{
if (service.Name == "DirectLine")
{
var directLineService = (GenericService)service;
DirectLineSecret = directLineService.Configuration["secret"];
}
break;
}
case ServiceTypes.Luis:
{
var luis = (LuisService)service;
var app = new LuisApplication(luis.AppId, luis.SubscriptionKey, luis.GetEndpoint());
var recognizer = new LuisRecognizer(app);
LuisServices.Add(luis.Name, recognizer);
break;
}
}
}
}
}
}