Adaptive Cards ColumnSet中Input.Text无法绑定指定id的Azure Bot Service问题
Adaptive Cards中ColumnSet内Input.Text值无法绑定指定ID的问题
我正在开发聊天机器人,使用Microsoft Adaptive Cards构建Bot UI。尝试创建包含2个TextBlock和2个Input.Text的行布局时,发现输入值无法绑定到指定的id;但将Input.Text移出ColumnSet改为堆叠排列后,值绑定就能正常工作。
已测试Web Chat、Teams Chat等不同渠道,该问题在Adaptive Card Designer中不存在,但在Azure Bot Service相关渠道中出现。想问有没有其他开发者遇到过同样的问题?
{ "type": "AdaptiveCard", "$schema": "http://adaptivecards.io/schemas/adaptive-card.json", "version": "1.3", "body": [ { "type": "ColumnSet", "columns": [ { "type": "Column", "width": "stretch", "items": [ { "type": "TextBlock", "text": "New TextBlock", "wrap": true }, { "type": "Input.Text", "id": "inputOne", "placeholder": "Placeholder text" } ] }, { "type": "Column", "width": "stretch", "items": [ { "type": "TextBlock", "text": "New TextBlock", "wrap": true }, { "type": "Input.Text", "id": "inputTwo", "placeholder": "Placeholder text" } ] } ] } ] }
不少开发者都遇到过类似问题,核心原因是Azure Bot Service对嵌套在ColumnSet中的Input组件的字段识别存在兼容性问题,尤其是Adaptive Card 1.3版本在部分渠道的实现中存在缺陷。
可以尝试这些方案来解决:
- 给ColumnSet和每个Column添加明确的
id属性,帮助服务端正确定位嵌套的Input组件 - 暂时将Adaptive Card版本降级到1.2测试,部分渠道对1.2版本的嵌套组件支持更稳定
- 如果是自定义Web Chat集成,可以通过中间件在提交卡片数据前,手动提取ColumnSet内Input的值并补充到提交的payload中
内容的提问来源于stack exchange,提问作者Linear Aphid
相关产品推荐
相关产品推荐

