Bot(V4)在基本选择提示的差异通道中显示不一致的结果

时间:2018-10-31 21:45:35

标签: c# botframework microsoft-teams

在不同通道中使用V4的Bot中,基本选择提示的结果不一致。另外,当我输入无效的选项时,它有时会将选项列表附加到某个通道中。不知道,我在做什么错。

例如在模拟器中 it shows like this which is perfect most of the time

例如,当我发布到azure网络应用程序bot时,正在进行网络聊天测试。它不会在框中显示选择,而是显示为建议列表,并且在我输入不正确的选项后还会附加选项列表。 see in portal Web chat

例如,在Microsoft Teams中,它不会在框中显示选择,而是显示为建议列表,并且在我输入不正确的选项后还会附加选项列表。 see here in Microsoft Teams

我的代码如下所示

    public MytestBotRootDialog()
        : base(nameof(PowerBICSSRootDialog))
    {
        this.rootChoices = new List<Choice>();
        this.rootChoices.Add(new Choice { Value = "Service"});
        this.rootChoices.Add(new Choice { Value = "Desktop"});
        this.rootChoices.Add(new Choice { Value = "Other"});

        var waterfallSteps = new WaterfallStep[]
        {
            PromptForRootChoicesAsync,
            RouteToSpecificDialogAsync,
            RepeatRootChoiceAsync
        };
        AddDialog(new WaterfallDialog(rootdialog, waterfallSteps));
        AddDialog(new ChoicePrompt(rootchoicesprompt));
        AddDialog(new ContentPackRootDialog());
    }

    private async Task<DialogTurnResult> PromptForRootChoicesAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
    {
        var opts = new PromptOptions
        {
            Prompt = MessageFactory.Text("Select the Area"),
            Choices = rootChoices,
            RetryPrompt = MessageFactory.Text("Please enter valid Area"),
        };

        return await stepContext.PromptAsync(rootchoicesprompt, opts, cancellationToken);
    }

    private async Task<DialogTurnResult> RouteToSpecificDialogAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
    {
        var selectedchoice = stepContext.Result as FoundChoice;
        var result = selectedchoice.Value.ToLowerInvariant();
        if (selectedchoice.Index == 0 || result.Contains("service"))
        {
            var context = stepContext.Context;
            await context.SendActivityAsync($"You Selected Service");
            return await stepContext.NextAsync();
        }
        else if (selectedchoice.Index == 1 || result.Contains("desktop"))
        {
            var context = stepContext.Context;
            await context.SendActivityAsync($"You Selected Dekstop");
            return await stepContext.NextAsync();
        }
        else if (selectedchoice.Index == 2 || result.Contains("other"))
        {
            return await stepContext.BeginDialogAsync(nameof(ContentPackRootDialog));
        }
        else
            return await stepContext.NextAsync();
    }
    private async Task<DialogTurnResult> RepeatRootChoiceAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
    {
        return await stepContext.ReplaceDialogAsync(rootdialog, null, cancellationToken);
    }

0 个答案:

没有答案