Automatically Bot display rating card after few seconds to take user feedback

丶灬走出姿态 提交于 2020-05-08 17:31:25

问题


I have a bot made using framework v4 in c#. I want that my bot take user feedback once the bot goes idle, or in the case user doesn't responded to bot.I have made my card but not getting any logic to implement above mention feature in my bot. I am also attaching the code of card i made. Also the image of my card. Can any look into it and help me out with this implementation. enter image description here

{
  "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": "normal"
      },
      "items": [
        {
          "type": "Image",
          "horizontalAlignment": "Center",
          "url": "https://upload.wikimedia.org/wikipedia/commons/1/18/Five-pointed_star.svg"
        },
        {
          "type": "TextBlock",
          "horizontalAlignment": "Center",
          "text": "normal"
        }
      ],
      "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:


There isn't a built-in way to do this, nor is there a "standard" suggestion. However, we typically recommend:

  1. On each message, start an asynchronous timer. You can do this in the bot, but it would be better to do outside of the bot, like with Azure Functions or something. The rest of this answer will assume the timer is outside of the bot. Ensure the timer also keeps track of the conversationReference related to the timer.
  2. Restart the timer each time the user matching that conversationReference sends a message
  3. Once the timer expires, send an event to the bot with the user and conversation information (maybe through ChannelData), letting the bot know the timer has expired. You could also create a separate endpoint and monitor there, so you don't need the activity scheme; instead of /api/messages, you could use something like /api/expiredTimers.
  4. Once the expired timer event is received, send a proactive message to the user to either 1) see if they're still there, or 2) end the conversation.


来源:https://stackoverflow.com/questions/60055694/automatically-bot-display-rating-card-after-few-seconds-to-take-user-feedback

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!