【发布时间】:2021-02-01 13:59:47
【问题描述】:
我在机器人框架中使用自适应卡片模板。当用户从下拉列表中选择特定值时,根据选择,输入表单卡上的少数输入字段应自动填充。如何做到这一点?
根据下拉菜单,如果用户选择“我自己”,他的电子邮件 ID 应自动填充到他/她的电子邮件地址文本框中(我可以从存储在用户状态中的用户配置文件中获取电子邮件地址)。 我使用的自适应卡如下:
{
"type": "AdaptiveCard",
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.2",
"body": [
{
"type": "TextBlock",
"text": "Please enter the email Id, on behalf of whom you want to raise the request.",
"wrap": true
},
{
"type": "Input.ChoiceSet",
"id":"dropdown",
"choices": [
{
"title": "Myself",
"value": "Myself"
},
{
"title": "Other",
"value": "Other"
}
],
"placeholder": "Raise request for"
},
{
"type": "Input.Text",
"id": "email",
"placeholder": "Enter email address here",
"validation": {
"necessity": "Required",
"errorMessage": "Email address is required"
}
},
{
"type": "ActionSet",
"actions": [
{
"type": "Action.Submit",
"title": "Submit",
"data": "Submit"
}
]
},
{
"type": "ActionSet",
"actions": [
{
"type": "Action.Submit",
"title": "Cancel",
"data": {
"id": "stepCancel"
}
}
]
}
]
}
我使用动作而不是动作集。卡片看起来像这样:
{
"type": "AdaptiveCard",
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.2",
"body": [
{
"type": "TextBlock",
"text": "Please enter the email Id, on behalf of whom you want to raise the request.",
"wrap": true
},
{
"type": "Input.ChoiceSet",
"id": "dropdown",
"choices": [
{
"title": "Myself",
"value": "Myself"
},
{
"title": "Other",
"value": "Other"
}
],
"placeholder": "Raise request for"
},
{
"type": "Input.Text",
"id": "email",
"placeholder": "Enter email address here",
"validation": {
"necessity": "Required",
"errorMessage": "Email address is required"
},
"inlineAction": {
"type": "Action.Submit",
"title": "Submit"
}
}
]
}
【问题讨论】:
-
到目前为止你有什么尝试?
-
目前,我根据每个下拉选择创建了两个自适应卡片,并根据代码中的 if 语句处理卡片的显示。我正在尝试看看这是否可能是客户端。
-
你能告诉我们你的代码和你的自适应卡片吗?你用的是什么频道?如果您使用网络聊天,这个答案应该可以帮助您提出客户端解决方案:stackoverflow.com/questions/60877533/…
-
你还在做这个吗?
-
我发现了一个我认为可能对这个用例有用的功能,即使用 'Conditional layout with $when' 链接docs.microsoft.com/en-us/adaptive-cards/templating/language
标签: c# json botframework adaptive-cards web-chat