在Microsoft Bot框架中,如何包括星级评分反馈

时间:2018-12-27 10:21:43

标签: botframework bots

我正在使用Microsoft Bot框架。我需要在代码中实现星级评价的反馈机制。就像选择星级一样,应提交机器人评级。谁可以帮我这个事?或任何建议?

1 个答案:

答案 0 :(得分:1)

您可以通过使列的行为类似于提交按钮来创建带有AdaptiveCard的星级评分反馈卡。首先,将一列设置添加到AdaptiveCard中,并设置所需的列数-每列将对应一个等级。然后,在每一列中,您可以添加星星或其他物体的图像以及描述该等级的文本字段。接下来,将提交操作添加到每一列,然后在数据字段中添加响应的值。最后,您可以渲染卡并将其作为附件发送给用户。当用户单击列时,它将从数据字段发送值作为用户的消息。有关示例,请参见下面的AdaptiveCard JSON和呈现的卡的屏幕截图。

屏幕截图

enter image description here

JSON AdaptiveCard

{
    "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"
}

希望这会有所帮助!