Bot Framework stuck in dialog loop

I am using the Bot Framework for one of my projects. It seems to be stuck in a loop, processing a response from the PromptDialog.Confirm function.

namespace Genome
{
public class InitiateDialog : IDialog<object>
{
    public async Task StartAsync(IDialogContext context)
    {
        context.Wait(ConversationStarted);
    }

    public async Task ConversationStarted(IDialogContext context, IAwaitable<IMessageActivity> message)
    {
        await context.PostAsync("Hi!");
        PromptDialog.Confirm(
            context: context,
            resume: ResumeAndPromptPlatformAsync,
            prompt: "Would you like to upload the document?",
            retry: "I didn't understand. Please try again."
            );
    }

    public async Task ResumeAndPromptPlatformAsync(IDialogContext context, IAwaitable<bool> result)
    {
        await context.PostAsync("Input Received");
    }
}
}

Executing this code never reaches the ResumeAndPromptPlatformAsync function. Each time I select “Yes / No” in PromptDialog.Confirm (), the Bot emulator goes back to start with ConversationStarted (), and asks the same question again.

+4
source share
1 answer

I think your current code is correct, but maybe there was an error in your previous code that caused the loop. Since the bot frame automatically saves state, you still stick to the old code.

facebook, "/deleteprofile" reset . , " " .

, ResumeAndPromptPlatformAsync context.Wait, context.Done, , .

: , context.Done(this);. .

public async Task ResumeAndPromptPlatformAsync(IDialogContext context, IAwaitable<bool> result)
{
    await context.PostAsync("Input Received");
    context.Done(this);
}
0

Source: https://habr.com/ru/post/1658449/


All Articles