Created
February 7, 2019 12:03
-
-
Save icebeam7/a4ec79a6327d28524058bda3cdfe602d to your computer and use it in GitHub Desktop.
WeatherBotv4 - BotServices.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using Microsoft.Bot.Builder.AI.Luis; | |
using Microsoft.Bot.Configuration; | |
namespace WeatherBotv4.Services | |
{ | |
public class BotService | |
{ | |
public BotService(BotConfiguration configuration) | |
{ | |
foreach (var s in configuration.Services) | |
{ | |
switch (s.Type) | |
{ | |
case ServiceTypes.Luis: | |
{ | |
var luis = (LuisService)s; | |
if (luis == null) | |
throw new InvalidOperationException("The LUIS service is not configured correctly in your '.bot' file."); | |
var app = new LuisApplication(luis.AppId, luis.AuthoringKey, luis.GetEndpoint()); | |
var recognizer = new LuisRecognizer(app); | |
this.LuisServices.Add(luis.Name, recognizer); | |
break; | |
} | |
} | |
} | |
} | |
public Dictionary<string, LuisRecognizer> LuisServices { get; } = new Dictionary<string, LuisRecognizer>(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment