首页 > 解决方案 > Allow users to multiselect option in BotFramework

问题描述

I would like my Bot make surveys. The problem is that in some questions, the user could select more than 1 answer.

How could I implement this scenario? Is there an official sample on how to do it with version 3 of the SDK?

Thank you!

标签: c#.netbotframework

解决方案


问题是在某些问题中,用户可以选择超过 1 个答案。

要使用户能够选择超过 1 个问题的答案,您可以使用AdaptiveChoiceSetInput来实现要求。以下代码片段供您参考。

card.Body.Add(new AdaptiveTextBlock()
{
    Text = "Q1:xxxxxxxx?",
    Size = AdaptiveTextSize.Default,
    Weight = AdaptiveTextWeight.Bolder
});

card.Body.Add(new AdaptiveChoiceSetInput()
{
    Id = "choiceset1",
    Choices = new List<AdaptiveChoice>()
    {
        new AdaptiveChoice(){
            Title="answer1",
            Value="answer1"
        },
        new AdaptiveChoice(){
            Title="answer2",
            Value="answer2"
        },
        new AdaptiveChoice(){
            Title="answer3",
            Value="answer3"
        }
    },
    Style = AdaptiveChoiceInputStyle.Expanded,
    IsMultiSelect = true
});

测试结果:

在此处输入图像描述


推荐阅读