在Bot Framework v4中,如何使用评论框和提交按钮实施评分卡 [英] In bot framework v4, how to implemente rating card with comment box and submit button

查看:59
本文介绍了在Bot Framework v4中,如何使用评论框和提交按钮实施评分卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用C#制作了bot框架V4.我已经在自适应卡中进行了星级评定,但是我需要在其中添加注释框并提交按钮,但是我的提交按钮不起作用.在调试模式下,它没有碰到任何bot方法.请帮帮我.我还将附加带有注释框和提交按钮的评分卡代码.

I have made a bot framework V4 using C#. I have made star rating in adaptive card but I need to add comment box and submit button in it,but my submit button is not working.In debugging mode its not hitting the any method of bot.Kindly help me. I am also attaching the code of my rating card having comment box and submit button in it.

 {
  "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有一些问题需要解决:

There's a couple of issues with your card JSON that you need to fix:

  1. 您的操作没有标题.
  2. 您应该使data成为对象而不是字符串.字符串在大多数情况下都有效,但不一致的地方.
  1. Your actions don't have titles.
  2. You should make data an object instead of a string. String works, mostly, but is less consistent.

您可以通过在设计器中复制/粘贴代码> 来查找/修复卡中的大多数错误,然后寻找错误:

You can find/fix most errors with your card by copy/pasting your code in the Designer and looking for errors:

我已经重新创建了您的卡,以便可以使用:

I've recreated your card so that it works:

{
    "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 Framework v4中,如何使用评论框和提交按钮实施评分卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆