简体   繁体   English

如何从自适应卡中取回消息

[英]How to get message back from Adaptive card

I use an adaptive card that has 2 actions.我使用具有 2 个动作的自适应卡。

"actions": [

    {
      "type": "Action.Submit",
      "title": "Cards related queries",
      "data": "Cards_intent"
    },
    {
      "type": "Action.Submit",
      "title": "Accounts related queries",
      "data": "Accounts_intent"
    }
]

But when the users select on action, I don't want the user to see "Accounts_intent" displayed in the chat box.但是当用户 select 开始行动时,我不希望用户看到聊天框中显示的“Accounts_intent”。 Instead, I want "Accounts related queries" to be displayed相反,我希望显示“与帐户相关的查询”

The issue:问题:

在此处输入图像描述

I think you have a few options 我想你有几个选择

Option #1 选项1

If you want to keep using an Adaptive Card and your only concern is what shows up in the conversation history, just change the string in the data property to whatever you want to be displayed. 如果要继续使用自适应卡,而您唯一关心的是对话历史记录中显示的内容,只需将data属性中的字符串更改为要显示的内容即可。

{
  "type": "Action.Submit",
  "title": "Accounts related queries",
  "data": "Accounts related queries"
}

Your bot must know to respond to an activity with "Accounts related queries" as the text. 您的漫游器必须知道如何以“与帐户相关的查询”为文本来响应活动。 Keep in mind that the user would also be able to type "Accounts related queries" to achieve the same result. 请记住,用户也可以键入“与帐户相关的查询”来获得相同的结果。

Option #2 选项#2

If you are using strings as your submit action data, your card must not have any input fields. 如果您使用字符串作为提交操作数据,则您的卡必须没有任何输入字段。 This means you can use any kind of rich card instead of an Adaptive Card, or you could even use suggested actions. 这意味着您可以使用任何种类的Rich Card代替Adaptive Card,或者甚至可以使用建议的操作。

If you definitely want your activity to contain different text from what the user sees in the conversation history, you will only be able to do this on channels that support it. 如果您确实希望自己的活动包含的内容与用户在对话历史记录中看到的内容不同,则只能在支持该内容的渠道上执行此操作。 Facebook Messenger lets you do this, but it does not support Adaptive Cards. Facebook Messenger允许您执行此操作,但它不支持自适应卡。 Having one set of visible text and another set of hidden data is often called a messageBack card action. 拥有一组可见文本和另一组隐藏数据通常称为messageBack卡动作。

Option #3 选项#3

If you don't care about the user seeing anything in the conversation history, you can either use craigbot's idea of having the submit action's data be an object instead of a string, or you can use a card action in a rich card other than an Adaptive Card. 如果您不希望用户在对话历史记录中看到任何内容,则可以使用craigbot的想法,即将“提交”操作的数据作为对象而不是字符串,或者可以在除“自适应卡。

If you'd like to learn more about Adaptive Cards and especially submit actions, please have a look at my latest blog post: https://blog.botframework.com/2019/07/02/using-adaptive-cards-with-the-microsoft-bot-framework/ 如果您想了解有关自适应卡的更多信息,尤其是提交操作,请查看我最新的博客文章: https : //blog.botframework.com/2019/07/02/using-adaptive-cards-with-微软机器人框架/

"actions": [

    {
      "type": "Action.Submit",
      "title": "Cards related queries",
      "data":{
                 "msteams":{
                       "type":"messageBack",
                       "displayText":"Cards related queries"
                   },
                   "value":"Cards_intent"
              }
    },
    {
      "type": "Action.Submit",
      "title": "Accounts related queries",
       "data":{
                 "msteams":{
                       "type":"messageBack",
                       "displayText":"Accounts relates queries"
                   },
                   "value":"Accounts_intent"
              }
    }
]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM