有没有办法在 C# 和 SDKV4 中创建的 MS Chat BOT 中使用 PromptOptions 突出显示通过 Choice 显示的按钮选项?

Is there a way to highlight a button option displayed through Choice using PromptOptions in MS Chat BOT created in C# and SDKV4?

我正在使用 C# 中使用 SDKV4 的 Microsoft Bot 框架创建聊天机器人。 BOT 有多个瀑布对话。

在这个对话框中 class 使用提示以按钮的形式显示了几个选项 Options.I 想知道是否或是否有办法突出显示的按钮中的一个(仅一个)不同的颜色。

如果我们观察,通常选择按钮显示为白色(按钮背景)和蓝色(蓝色文本和按钮边框)组合。

那么有没有办法改变白色背景颜色?要么只有颜色,要么让按钮根据特定条件给出闪烁效果或闪烁效果。

假设有一个 bool 标志,如果它是真的我想显示其他颜色的选项之一或者如果它是假的。

代码:

 return await stepContext.PromptAsync(
                        "choicePrompt",
                        new PromptOptions
                        {
                            Prompt = stepContext.Context.Activity.CreateReply("Please click/choose any one from the following: "),
                            Choices = new[] { new Choice { Value = "Option0" }, new Choice { Value = "Option1" }, new Choice { Value = "Option2" }, new Choice { Value = "Option3" }, new Choice { Value = "Option4" }, new Choice { Value = "Option5" }}.ToList(),
                            RetryPrompt = stepContext.Context.Activity.CreateReply("Sorry, I did not understand that. Please choose any one from the options displayed below: "),
                        });

我希望 Option2 根据上面解释的 Bool 标志以不同的颜色显示。

这可能吗?或者这是一个错误的期望,无法做到?

如果可能的话,任何人都可以向我提供实现此目的的详细步骤。请注意,我对编码有点陌生,因此,如果这是可以实现的行为,我会谦虚地请求提供详细的步骤。

提前致谢

此致

ChaitanyaNG

没有内置的方法可以做到这一点,不。最接近 PromptOptions offers is the Style property, but even that is only for setting different ListStyles,none 其中提供任何颜色定制。

如果您只使用网络聊天,可能有一些 CSS 自定义我可以帮助您。但是,如果您正在使用任何其他渠道,那么您几乎无法确定该渠道如何决定呈现选择。

或者,您可以发送小型自适应卡片并设置不同的 background image for the first one. Note, however, that the channel doesn't have to display the background image (although it likely will). Non-Microsoft channels (Slack, Facebook, etc) also don't work very well with using Adaptive Cards as inputs


为了回答进一步的评论,我找到了合适的 CSS 选择器。这可能与您的网络聊天版本不同,但我使用了:

.css-1wegtiu > ul > li:first-child > .css-y5o52s > button {
    background: red
}

这导致: