json - 如何使用 messageBack 或 imBack 从 ChoiceSet 中回显用户选择选项集?
问题描述
我正在尝试使用 messageBack 或 imBack (无论哪个可能)从给定的用户评分下拉列表中回显用户选择的选项。因为,我只能在 messageBack 值字段中添加静态文本作为值
"actions": [
{
"type": "Action.Submit",
"title": "OK",
"data": {
"msteams": {
"type": "imBack",
"value": "User selected option"
}
}
}
]
有没有一种方法可以让我从选择集中获取价值并显示在 MS Teams 上使用 messageBack?
您可以在此处参考完整的 JSON:
{
"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 - 你能检查一下这个代码吗?
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"
},
},
}
推荐阅读
- google-sheets - 如何有效地使用 Google 表格中的公式将范围内的最新值与基于多个标准的平均值进行比较?
- javascript - 如何根据字符串输入更新一个 Mongo 文档 Node.js?
- firebase - 购物车如何在使用 firebase 作为后端的 react 本机应用程序中工作
- c# - 不包含“ReturnsAsync”的定义和最佳扩展方法重载
- php - 防止用户在登录后返回登录表单?
- javascript - 异步 TS/JS 函数中的全局赋值是否安全,不会意外覆盖现有值?
- virtual-machine - 如果我的 VirtualBox 克隆永远不会同时运行,我是否需要一个新的 MAC 地址?
- java - 编写基于 SonarQube Java 的规则来检查 assertj 错误,无法确定何时不调用链式方法
- oracle - Oracle CLOB 数据类型给出错误:`SQL 错误:ORA-01704:字符串文字太长`
- python - 感知器没有正确学习