botframework - 在 Microsoft bot 框架中,如何包含星级反馈
问题描述
我正在使用微软机器人框架。我需要在我的代码中实现星级反馈机制。喜欢选择星星应该提交机器人的评级。谁可以帮我这个事?或任何建议?
解决方案
您可以通过使列的行为类似于提交按钮来创建带有 AdaptiveCard 的星级反馈卡。首先,将列集添加到具有所需列数的 AdaptiveCard - 每列将对应一个评级。然后在每一列中,您可以添加星星或其他对象的图像以及描述该评级的文本字段。接下来,向每一列添加一个提交操作,并在数据字段中添加响应的值。最后,您可以渲染卡片并将其作为附件发送给用户。当用户点击一列时,它会将数据字段中的值作为来自用户的消息发送。有关示例,请参阅下面呈现的卡片的 AdaptiveCard JSON 和屏幕截图。
截屏
JSON 自适应卡片
{
"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"
}
]
}
],
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.0"
}
推荐阅读
- python - AWS Lambda 函数可以从 python 文件中调用另一个普通的 python 函数吗?
- haskell - 如何在 optparse-applicative 中重写 --help 标志输出
- javascript - 硬重载真的适用于 location.reload(true) 吗?
- javascript - 是否可以使用纯 JavaScript 访问 Angular *ngFor 的对象值?
- angular - 如何将数据从 API 加载到输入字段?
- python - 如何使用 matplotlib 执行条件区域绘图?
- python - 循环并打印json文件python的每个变量
- node.js - 如何在 NestjS 中使用可选的 url 参数
- python-3.x - 如何将字典值传递给不同类python中的算术函数
- sql - 数据库中的哪个查询更好?