如何使用messageBack或imBack从choiceSet中回显用户选择的选项集? [英] How to echo user select optionset from ChoiceSet using messageBack or imBack?

查看:93
本文介绍了如何使用messageBack或imBack从choiceSet中回显用户选择的选项集?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用messageBack或imBack(尽可能)从给定的用户评分下拉列表中回显用户选择的选项.因为,我只能在messageBack值字段中添加静态文本作为值

I am trying to echo the user selected option from given set of user rating drop down using messageBack or imBack (whichever is possible). Since, I am only able to add a static text as value in messageBack value field

"actions": [
    {
      "type": "Action.Submit",
      "title": "OK",
      "data": {
        "msteams": {
          "type": "imBack",
          "value": "User selected option"
        }
      }
    }
  ]

是否有一种方法可以从choiceset中获取值并显示是否在MS Teams上使用messageBack?

Is there a way that I can get the value from choiceset and show is using messageBack on MS Teams?

您可以在此处引用完整的JSON:

You can refer to complete JSON here:

{
  "type": "AdaptiveCard",
  "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
  "version": "1.2",
  "body": [
    {
      "type": "TextBlock",
      "size": "Medium",
      "weight": "Bolder",
      "color": "Accent",
      "text": "Rate your experience!"
    },
    {

      "type": "TextBlock",
      "separator": true,
      "text": "Please rate your experience! Your feedback is very appreciated and will help improve your experience in the future. ",
      "wrap": true
    },
    {
      "type": "Input.ChoiceSet",
      "id": "CompactSelect",
      "label": "What color do you want? (compact)",
      "style": "compact",
      "isRequired": true,
      "errorMessage": "This is a required input",
      "placeholder": "Please choose",
      "choices": [
        {
          "title": "⭐⭐⭐⭐⭐",
          "value": "⭐⭐⭐⭐⭐"

        },
        {
          "title": "⭐⭐⭐⭐",
          "value": "⭐⭐⭐⭐"
        },
        {
          "title": "⭐⭐⭐",
          "value": "⭐⭐⭐"

        },
        {
          "title": "⭐⭐",
          "value": "⭐⭐"

        },
        {
          "title": "⭐",
          "value": "⭐"
        }
      ]
    }
  ],
  "actions": [
    {
      "type": "Action.Submit",
      "title": "OK",
      "data": {
        "msteams": {
          "type": "imBack",
          "value": "User selected option"
        }
      }
    }
  ]

}

推荐答案

@ user30-您能否检查此代码?

@user30 - Could you please check this Code?

var InputChoices = new List<AdaptiveChoice> {
          new AdaptiveChoice() { Title = "Red",
            Value = "Red" },
        new AdaptiveChoice() { Title = "Green",
            Value = "Green" },
  new AdaptiveChoice() { Title = "White",
            Value = "White" },
  new AdaptiveChoice() { Title = "Black",
            Value = "Black" }
   };
 return new AdaptiveCard()
      {
        Body = new List<AdaptiveElement>()
                {
 new AdaptiveColumnSet()
                    {
                        Columns=new List<AdaptiveColumn>()
                        {
                            new AdaptiveColumn()
                            {
                                Items=new List<AdaptiveElement>()
                                {
                                    new AdaptiveTextBlock()
                                    {
                                        Text="Colors",
                                        Id="colorCodeId",
                                        Spacing=AdaptiveSpacing.None,
                                        Wrap=true
                                    }
                                }
                            },
                            new AdaptiveColumn()
                            {
                                Items=new List<AdaptiveElement>()
                                {
                                    new AdaptiveChoiceSetInput()
                                    {
                                        Id="colorCodeId",
                                        Spacing=AdaptiveSpacing.None,
                                        Choices=new List<AdaptiveChoice>(InputChoices),
                                        Style=AdaptiveChoiceInputStyle.Compact
                                    }
                                }
                            }
                        }
                    },
                },
        Actions = new List<AdaptiveAction>()
                {
                    new AdaptiveSubmitAction
                    {
                        Type = AdaptiveSubmitAction.TypeName,
                        Title = "Submit"
                 },
                },
      }

这篇关于如何使用messageBack或imBack从choiceSet中回显用户选择的选项集?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆