TSR
TSR

Reputation: 20617

How to get message back from Adaptive card

I use an adaptive card that has 2 actions.

"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. Instead, I want "Accounts related queries" to be displayed

The issue:

enter image description here

Upvotes: 2

Views: 3698

Answers (2)

Swati Singh
Swati Singh

Reputation: 1

The simple one word answer is messageBack. You can use this in data:{} and mention the text that you'd like to be shown from user side in displayText and you'll be able to get a text back from user side when they click on any of the button.

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

Upvotes: 0

Kyle Delaney
Kyle Delaney

Reputation: 12284

I think you have a few options

Option #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.

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

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.

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. Having one set of visible text and another set of hidden data is often called a messageBack card action.

Option #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.

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/

Upvotes: 4

Related Questions