botframework-sdk icon indicating copy to clipboard operation
botframework-sdk copied to clipboard

BasicQnAMakerDialog throw an error when I call from RootDialog

Open JeevaJose opened this issue 9 years ago • 4 comments

I am using “Microsoft.Bot.Builder.CognitiveServices.QnAMaker” to invoke the QNA service. I calling the BasicQnAMakerDialog inside the Rootdialog and when hit the line “var message = await argument;” throwing a error, the error msg has given below. Please let me know what is the correct implementation I have to follow to fix the issue

“invalid type: expected Microsoft.Bot.Connector.IMessageActivity, have Boolean”

public class RootDialog : IDialog<object>
    {
        public Task StartAsync(IDialogContext context)
        {
            context.Wait(MessageReceivedAsync);

            return Task.CompletedTask;
        }

        private async Task MessageReceivedAsync(IDialogContext context, IAwaitable<object> result)
        {
            var activity = await result;

            await context.Forward(
                new BasicQnAMakerDialog(),
                ConvEndAsync,
                activity,
                System.Threading.CancellationToken.None);

            context.Wait(MessageReceivedAsync);
        }

        public async Task ConvEndAsync(IDialogContext context, IAwaitable<object> argument)
        {
            try
            {
                var message = await argument;
            }
            catch (Exception ex)
            {
                
            }
            context.Wait(MessageReceivedAsync);
        }
    }

JeevaJose avatar May 14 '17 12:05 JeevaJose

Remove the context.Wait(MessageReceivedAsync); from the MessageReceivedAsync. You are forwarding messages to another dialog so you don't need to wait on this one.

ejadib avatar May 14 '17 14:05 ejadib

Still have the same error for me

AdrienHt avatar Jun 16 '17 12:06 AdrienHt

I am facing the same issue. There isn't a cont.wait in my code. Can you help?

tringtring avatar Jul 29 '17 22:07 tringtring

Still have the same error for me. Is the correct implementation for ConvEndAsync simply ?

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

digitalanalogue9 avatar Oct 26 '17 08:10 digitalanalogue9