Bot (V4) shows inconsistent results in diff channel for basic choiceprompt

Viewed 122

I am getting inconsistent result for a basic choice prompt in Bot using V4 in different channel. Also when i enter invalid options, it sometime appends the option list in some channle. not sure, what i am doing wrong.

e.g in Emulator it shows like this which is perfect most of the time

e.g when i publish to azure web app bot, in test in web chat. it does not show choice in boxes but show as suggestion list and also appends the list of options after i enter incorrect option. see in portal Web chat

e.g in Microsoft Teams, it does not show choice in boxes but shows as suggestion list and also appends the list of options after i enter incorrect option. see here in Microsoft Teams

My code is like below

    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 Answers
Related