В фреймворке ботов v4, как реализовать оценочную карту с полем для комментариев и кнопкой отправки - PullRequest
2 голосов
/ 27 января 2020

Я создал бот-фреймворк V4, используя C#. Я сделал звездный рейтинг в адаптивной карточке, но мне нужно добавить поле для комментариев и кнопку отправки в нем, но моя кнопка отправки не работает. В режиме отладки не работает ни один метод бота. Пожалуйста, помогите мне. Я также прикрепляю код моей оценочной карты с полем для комментариев и кнопкой отправки.

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

1 Ответ

2 голосов
/ 27 января 2020

Есть несколько проблем с вашей картой JSON, которые вам нужно исправить:

  1. Ваши действия не имеют заголовков.
  2. Вы должны сделать data an объект вместо строки. Строка в основном работает, но менее последовательна.

Вы можете найти / исправить большинство ошибок с вашей картой, скопировав / вставив код в Designer и найдя ошибки:

enter image description here

Я пересоздал вашу карту, чтобы она работала:

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

...