Skip to content

Instantly share code, notes, and snippets.

@icebeam7
Created February 7, 2019 12:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save icebeam7/a4ec79a6327d28524058bda3cdfe602d to your computer and use it in GitHub Desktop.
Save icebeam7/a4ec79a6327d28524058bda3cdfe602d to your computer and use it in GitHub Desktop.
WeatherBotv4 - BotServices.cs
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