1
votes

I am trying to implement a QnaMakerDialog after LUIS recognizes that it is a QnA Intent. In my Dialogs folder, I have two files: BasicLuisDialog.cs and BasicQnAMakerDialog.cs. In my Controller, it calls BasicLuisDialog, and I want to call the QnAMakerDialog within that. Here is my full BasicLuisDialog code:

using System;
using System.Configuration;
using System.Threading.Tasks;
using System.Web.Http;

using Microsoft.Bot.Connector;
using Microsoft.Bot.Builder.Dialogs;
using System.Web.Http.Description;
using System.Net.Http;
using System.Diagnostics;
using Microsoft.Bot.Builder.Luis;
using Microsoft.Bot.Builder.Luis.Models;
using System.Threading;
using Microsoft.Bot.Sample.QnABot;




namespace Microsoft.Bot.Sample.LuisBot
{
    [Serializable]
    public class BasicLuisDialog : LuisDialog<object>
    {
        public BasicLuisDialog() : base(new LuisService(new LuisModelAttribute("asdf", "asdf")))
//replace asdf with keys 
        {
        }

        [LuisIntent("None")]
        public async Task NoneIntent(IDialogContext context, LuisResult result)
        {
            await context.PostAsync($"You have reached the none intent. You said: {result.Query}"); //
            context.Wait(MessageReceived);
        }

        [LuisIntent("Weather.GetCondition")]
        public async Task ConditionIntent(IDialogContext context, LuisResult result)
        {
            await context.PostAsync($"You have reached the Condition intent. You said: {result.Query}"); //
            context.Wait(MessageReceived);
        }

        [LuisIntent("Weather.GetForecast")]
        public async Task ForecastIntent(IDialogContext context, LuisResult result)
        {
            await context.PostAsync($"You have reached the ForecastIntent intent. You said: {result.Query}"); //
            context.Wait(MessageReceived);
        }

        [LuisIntent("GetQnA")]
        public async Task GetQnA(IDialogContext context, IAwaitable<IMessageActivity> activity, LuisResult result)
        {
        var msg = await activity;
        var cts = new CancellationTokenSource();
        var faq = new BasicQnAMakerDialog();
        await context.Forward(faq, AfterFAQDialog, msg, CancellationToken.None);

        }

        private async Task AfterFAQDialog(IDialogContext context, IAwaitable<object> result)
        {
        context.Wait(MessageReceived);
        }

    }
}

I get the error:

Dialogs\BasicLuisDialog.cs(51,23): error CS0246: The type or namespace name 'BasicQnAMakerDialog' could not be found (are you missing a using directive or an assembly reference?)

Code for BasicQnAMakerDialog.cs:

using System;
using System.Configuration;

using Microsoft.Bot.Builder.CognitiveServices.QnAMaker;

namespace Microsoft.Bot.Sample.QnABot
{
    [Serializable]
    public class BasicQnAMakerDialog : QnAMakerDialog
    {
        public BasicQnAMakerDialog() : base(new QnAMakerService(new QnAMakerAttribute("asdf", "asdf","No good match in FAQ",0.2,3))) 
        {
        }

        protected override async Task DefaultWaitNextMessageAsync(IDialogContext context, IMessageActivity message, QnAMakerResults results)
        {
            Console.WriteLine("KB Question: " + results.Answers.First().Questions.First());
            Console.WriteLine("KB Answer: " + results.Answers.First().Answer);
            await base.DefaultWaitNextMessageAsync(context, message, results);
        }
    }

}
1
Can you post the top of the class? the usingsEzequiel Jadib
using System; using System.Configuration; using System.Threading.Tasks; using System.Web.Http; using Microsoft.Bot.Connector; using Microsoft.Bot.Builder.Dialogs; using System.Web.Http.Description; using System.Net.Http; using System.Diagnostics; using Microsoft.Bot.Builder.Luis; using Microsoft.Bot.Builder.Luis.Models;Sharon Fang
CancellationToken is in System.Threading, so you should also have "using System.Threading;" I'm not sure why BasicQnAMakerDialog isn't found. Please add the entire dialog's code, as it is, to the question.Eric Dahlvang
Updated. The using System.Threading got rid of the first error.Sharon Fang
What namespace is your BasicQnAMakerDialog in?Zhaph - Ben Duguid

1 Answers

0
votes

Add a using for the namespace where the BasicQnAMakerDialog.cs is at.

using Microsoft.Bot.Sample.QnABot