Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Microsoft.Rest.HttpOperationException in Microsoft.Bot.Builder.dll ("Access Denied") while testing PromptDialog.Confirm

I'm trying to test the IDialog Flow with a fake Message so:

        var toBot = new Message()
        {
            ConversationId = Guid.NewGuid().ToString(),
            Text = "Test",
        };

        Func<IDialog<T>> MakeRoot = () => testDialog;
        toBot.From = new ChannelAccount(Guid.NewGuid().ToString());
        toBot.To = new ChannelAccount(Guid.NewGuid().ToString());

When it hits the PromptDialog.Confirm, it throws the "Microsoft.Rest.HttpOperationException in Microsoft.Bot.Builder.dll ("Access Denied")" exception.

If I don't create

        toBot.From = new ChannelAccount(Guid.NewGuid().ToString());

it throws System.NullReferenceException for ChannelId.

PromptDialog.Confirm looks like this:

    PromptDialog.Confirm(context, AfterErrorConfirmationAsync, Strings.ConfirmError,
                Strings.InvalidInput);

How can I work around this issue?

like image 478
Vish Avatar asked Oct 30 '22 03:10

Vish


1 Answers

The issue was caused by this:

    await context.PostAsync(replyMessage);
    PromptDialog.Confirm(context, AfterErrorConfirmationAsync, Strings.ConfirmError,
            Strings.InvalidInput);

Having a confirm dialog immediately after posting a message to the user caused the exception and subsequently test failure. It did not throw this exception during run time though.

I resolved the above issue by combining the reply message with the confirmation string as follows:

    PromptDialog.Confirm(context, AfterErrorProcessingAsync, replyMessage + "\n\n" + Strings.ConfirmError,
                Strings.InvalidInput);

Leaving this question open if someone has a better workaround.

like image 116
Vish Avatar answered Nov 15 '22 06:11

Vish