在bot框架v4中,如何通过评论框和提交按钮实施评分卡
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了在bot框架v4中,如何通过评论框和提交按钮实施评分卡相关的知识,希望对你有一定的参考价值。
我已经使用C#制作了bot框架V4。我已经在自适应卡中进行了星级评分,但是我需要在其中添加注释框并提交按钮,但是我的提交按钮不起作用。在调试模式下,它没有碰到任何bot方法。请帮助我。我还将附加带有注释框和提交按钮的评分卡代码。
"type": "AdaptiveCard",
"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": "ColumnSet",
"spacing": "Medium",
"columns": [
"type": "Column",
"selectAction":
"type": "Action.Submit",
"data": "awful"
,
"items": [
"type": "Image",
"horizontalAlignment": "Center",
"url": "https://upload.wikimedia.org/wikipedia/commons/1/18/Five-pointed_star.svg"
,
"type": "TextBlock",
"horizontalAlignment": "Center",
"text": "Awful"
],
"width": "stretch"
,
"type": "Column",
"selectAction":
"type": "Action.Submit",
"data": "bad"
,
"items": [
"type": "Image",
"horizontalAlignment": "Center",
"url": "https://upload.wikimedia.org/wikipedia/commons/1/18/Five-pointed_star.svg"
,
"type": "TextBlock",
"horizontalAlignment": "Center",
"text": "Bad"
],
"width": "stretch"
,
"type": "Column",
"selectAction":
"type": "Action.Submit",
"data": "ok"
,
"items": [
"type": "Image",
"horizontalAlignment": "Center",
"url": "https://upload.wikimedia.org/wikipedia/commons/1/18/Five-pointed_star.svg"
,
"type": "TextBlock",
"horizontalAlignment": "Center",
"text": "Ok"
],
"width": "stretch"
,
"type": "Column",
"selectAction":
"type": "Action.Submit",
"data": "good"
,
"items": [
"type": "Image",
"horizontalAlignment": "Center",
"url": "https://upload.wikimedia.org/wikipedia/commons/1/18/Five-pointed_star.svg"
,
"type": "TextBlock",
"horizontalAlignment": "Center",
"text": "Good"
],
"width": "stretch"
,
"type": "Column",
"selectAction":
"type": "Action.Submit",
"data": "terrific"
,
"items": [
"type": "Image",
"horizontalAlignment": "Center",
"url": "https://upload.wikimedia.org/wikipedia/commons/1/18/Five-pointed_star.svg"
,
"type": "TextBlock",
"horizontalAlignment": "Center",
"text": "Terrific"
],
"width": "stretch"
]
,
"type": "Input.Text",
"id": "comment",
"placeholder": "Add a comment",
"isMultiline": true
],
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.0",
"actions": [
"type": "Action.Submit",
"title": "Ok",
"data": "ok"
]
答案
您的卡JSON有几个问题需要解决:
- 您的操作没有标题。
- 您应该使
data
成为对象而不是字符串。字符串在大多数情况下都有效,但是不一致的地方。
您可以通过复制/粘贴代码in the Designer并查找错误来查找/修复卡中的大多数错误:
我已经重新创建了您的卡,以便可以使用:
"type": "AdaptiveCard",
"body": [
"type": "TextBlock",
"text": "Rate your experience!",
"weight": "Bolder",
"color": "Accent",
"size": "Medium"
,
"type": "TextBlock",
"text": "Please rate your experience! Your feedback is very appreciated and will help improve your experience in the future. ",
"wrap": true
,
"type": "ColumnSet",
"columns": [
"type": "Column",
"width": "stretch",
"items": [
"type": "Image",
"altText": "",
"url": "https://upload.wikimedia.org/wikipedia/commons/1/18/Five-pointed_star.svg",
"selectAction":
"type": "Action.Submit",
"data": "rating": "awful" ,
"title": "awful"
]
,
"type": "Column",
"width": "stretch",
"items": [
"type": "Image",
"altText": "",
"url": "https://upload.wikimedia.org/wikipedia/commons/1/18/Five-pointed_star.svg",
"selectAction":
"type": "Action.Submit",
"data": "rating": "bad" ,
"title": "bad"
]
,
"type": "Column",
"width": "stretch",
"items": [
"type": "Image",
"altText": "",
"url": "https://upload.wikimedia.org/wikipedia/commons/1/18/Five-pointed_star.svg",
"selectAction":
"type": "Action.Submit",
"data": "rating": "ok" ,
"title": "ok"
]
,
"type": "Column",
"width": "stretch",
"items": [
"type": "Image",
"altText": "",
"url": "https://upload.wikimedia.org/wikipedia/commons/1/18/Five-pointed_star.svg",
"selectAction":
"type": "Action.Submit",
"data": "rating": "good" ,
"title": "good"
]
,
"type": "Column",
"width": "stretch",
"items": [
"type": "Image",
"altText": "",
"url": "https://upload.wikimedia.org/wikipedia/commons/1/18/Five-pointed_star.svg",
"selectAction":
"type": "Action.Submit",
"data": "rating": "terrific" ,
"title": "terrific"
]
]
,
"type": "Input.Text",
"placeholder": "Add a comment",
"isMultiline": true,
"id": "comment"
],
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.0",
"actions": [
"type": "Action.Submit",
"title": "Ok"
]
注意,反馈将来自Activity.Value.rating
以上是关于在bot框架v4中,如何通过评论框和提交按钮实施评分卡的主要内容,如果未能解决你的问题,请参考以下文章
如何在基于Bot framewok v4构建的团队聊天机器人中启用语音功能
从模板部署和运行 bot 框架 v4.4+ 有效,但使用 fork 和源代码控制部署和运行不起作用
如何使用 C# 添加通过卡片内的提示选项显示的自定义选项并在 BOT V4 中使用 C# 在选择单击时触发操作?