AdaptiveCards icon indicating copy to clipboard operation
AdaptiveCards copied to clipboard

Action.Submit postBack Behavior

Open jfb74 opened this issue 9 years ago • 5 comments

I am wondering how to emulate the HeroCard postBack behavior with AdaptiveCards. I see in the documentation it says that "The data property of the action may be a string or it may be an object. A string is passed back to your bot as a Bot Builder SDK imBack activity, and an object is passed as a postBack activity"

My question is that with a HeroCard the postBack text is just a string but if I pass just a string to the data element for the AdaptiveCard it shows up in the Chat window and I don't want that. Is there anyway to have the AdaptiveCard behave like the HeroCard or will I have to modify my bot to accept an object instead of a string when matching on the postBack?

jfb74 avatar Aug 16 '17 14:08 jfb74

For anyone who encounters this issue in the future, the solution is as follows. As part of the data you have to include a flag which is set to true, and then you can set the value to the typical text as would be set in the HeroCard.

HeroCard: builder.CardAction.postBack(session, "show_All_Incidents", "View Incident(s)")

AdaptiveCard: { "type": "Action.Submit", "title": "View Incident(s)", "data":{"__isBotFrameworkCardAction": true, "type": "postBack", "value": "show_All_Incidents"}
}

jfb74 avatar Aug 16 '17 15:08 jfb74

Hi @jfb74 - can you file this issue in the WebChat repo?

danmarshall avatar Aug 17 '17 00:08 danmarshall

@danmarshall I have closed the issue and provided the solution I found above, is there more you advise I should do?

jfb74 avatar Aug 17 '17 00:08 jfb74

@jfb74 If others want this behavior, then perhaps this should be a core feature :) so I would like to track it. Thanks for the feedback and contribution!

danmarshall avatar Aug 17 '17 01:08 danmarshall

@danmarshall Luckily enough there is a solution which works properly now. Though it definitely would be good to have a more user friendly or more official solution on how to do this. I appreciate your response though!

jfb74 avatar Aug 17 '17 01:08 jfb74