Beispiel #1
0
 private async Task DispatchToTopIntentAsync(ITurnContext <IMessageActivity> turnContext, string intent, RecognizerResult recognizerResult, CancellationToken cancellationToken)
 {
     if (KbLuisMap.GetMap().ContainsKey(intent))
     {
         var qnaService = _botServices.GetServiceForIntent(intent);
         await ProcessSampleQnAAsync(turnContext, cancellationToken, qnaService);
     }
     else
     {
         //_logger.LogInformation($"Dispatch unrecognized intent: {intent}.");
         await turnContext.SendActivityAsync(MessageFactory.Text($"Dispatch unrecognized intent: {intent}."), cancellationToken);
     }
 }
Beispiel #2
0
        public BotServices(IConfiguration configuration)
        {
            QnAMakerServiceList = new Dictionary <string, QnAMaker>();

            Dispatch = new LuisRecognizer(new LuisApplication(
                                              configuration["LuisAppId"],
                                              configuration["LuisAPIKey"],
                                              $"https://{configuration["LuisAPIHostName"]}"),
                                          new LuisPredictionOptions {
                IncludeAllIntents = true, IncludeInstanceData = true
            },
                                          includeApiResults: true);

            foreach (var kbitem in KbLuisMap.GetMap())
            {
                QnAMakerServiceList.Add(kbitem.Key, new QnAMaker(new QnAMakerEndpoint
                {
                    KnowledgeBaseId = kbitem.Value,
                    EndpointKey     = configuration["QnAEndpointKey"],
                    Host            = GetHostname(configuration["QnAEndpointHostName"])
                }));
            }
        }