BotFramework-WebChat icon indicating copy to clipboard operation
BotFramework-WebChat copied to clipboard

Action.ShowCard does not works in selectAction

Open puripuneet opened this issue 8 years ago • 17 comments

When an image with a "selectAction" type of "Action.ShowCard" (please see the attached JSON) is clicked, WebChat does not display the card. However, the same functionality does work in the Microsoft Visualizer, which does display the nested card as a popup.

Note: Tried changing the "actionMode" property in adaptivecards-hostconfig.json from its default value of "inlineEdgeToEdge" to "popup", but that didn't help either.

adaptive-card-nested-in-image.json.txt

puripuneet avatar Jan 26 '18 22:01 puripuneet

I don't think we currently support ShowCardAction inside selectAction. @danmarshall @eanders-MS can you comment on it?

I traced the code and it reached here.

compulim avatar Mar 09 '18 01:03 compulim

It should be supported, but it is not implemented yet. It was dependent on a resize event from the Adaptive Card which did not exist at that time. Looks like it has recently been implemented in AdaptiveCards: https://github.com/Microsoft/AdaptiveCards/issues/431 ...so someone can now add the code to listen for this resize event, and resize the WebChat message (and manage the scroll location, etc.)

danmarshall avatar Mar 09 '18 01:03 danmarshall

Or should we show another card below when the user click on ShowCard? Because from the behavioral view, it is actually opening a new dialog.

compulim avatar Mar 09 '18 02:03 compulim

It should be the same as the Visualizer

danmarshall avatar Mar 09 '18 02:03 danmarshall

If you copy @puripuneet JSON to the visualizer, it looks like this, opening a modal dialog (the background is a bit dimmed).

image

I have cleaned the JSON so it's for anyone to copy.

{
    "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
    "type": "AdaptiveCard",
    "version": "1.0",
    "body": [
        {
            "type": "Image",
            "url": "http://adaptivecards.io/content/cats/1.png",
            "selectAction": {
                "type": "Action.ShowCard",
                "title": "Action.ShowCard",
                "card": {
                    "type": "AdaptiveCard",
                    "body": [
                        {
                            "type": "TextBlock",
                            "text":"What do you think?"
                        }
                    ],
                    "actions": [
                        {
                            "type":"Action.Submit",
                            "title":"Neat!"
                        }
                    ]
                }
            }
        }
    ]
}

compulim avatar Mar 09 '18 02:03 compulim

@matthidinger - can you tell us why some Action.ShowCard actions show a modal while others appear inline?

danmarshall avatar Mar 09 '18 03:03 danmarshall

@danmarshall my layman's guess is that when the Action.ShowCard is nested inside an image, it always results in the adaptive card showing as a modal because an image is static and doesn't have "real estate" to resize in order to show the adaptive card inline. Whereas, an adaptive card nested inside another adaptive card can resize and show as inline (but note in this case that the "actionMode" property in adaptivecards-hostconfig.json is what should control whether it shows as inline or modal).

puripuneet avatar Mar 09 '18 04:03 puripuneet

We actually never officially supported ShowCard in a selectAction because we haven't had time to properly vet the experience everywhere and with every known Host so we err'd on the side of caution and didn't support it for 1.0.

The docs here mention that Action.ShowCard is not supported in selectAction today. http://adaptivecards.io/explorer/Image.html

Hopefully we can look into this in a future release. I haven't seen many requests for it yet, but if you folks are getting feedback that this is an important scenario we can dive in.

matthidinger avatar Apr 13 '18 18:04 matthidinger

I was really hoping for a workaround for this issue. I just have some regular items shown as a list and some items need to have a checkbox or maybe two radiobuttons I like to hide initially, only to be shown if you select an item.. I wanted to prevent a situation where i have to create multiple cards to tackle this.

I would really appreciate if this feature would be allowed as it gives a lot of extra alternatives for developers like myself. At the moment I find myself fighting the adaptive cards to find a workaround for most common UX solutions. I understand its in preview, but it makes it a bit more difficult as you cant work from common expectations.

mennolaan avatar Jun 14 '18 09:06 mennolaan

@mennolaan are you using Adaptive Cards for form-filling + validation?

compulim avatar Jun 14 '18 17:06 compulim

@compulim Yes and no, the checkboxes are just part of the total information I'm going to send.

mennolaan avatar Jun 15 '18 09:06 mennolaan

Customizable activity bubble is coming.

But if you are more into form-filling/validation, it is coming too. But it's a little bit different. It works by filling the form outside of the Web Chat component, but on the same page. We think this is better than inline form filling because:

  1. Simple form-filling can be done by Adaptive Cards (without logic)
  2. Form with logic can be implemented on the web page using HTML5 Validation API, and Web Chat interface with it
    • HTML5 Validation API is good because you don't need to worry about localization and accessibility
    • You can leverage your existing validation logic (if you have any), i.e. Web Chat help you to fill the existing form

compulim avatar Jun 15 '18 10:06 compulim

Can you please tell me why adaptive cards is not working for facebook as same is working in Emulator? And also button list in facebook getting break after count of three? buttonemulator===> Button for Emulator buttonfb===>Button for fb adaptiveemulator===>adaptive for Emulator adaptivefb===>adaptive for fb

pankajGODB avatar Jun 27 '18 12:06 pankajGODB

@pankajGODB is it Adaptive Cards or a rich card (hero card) for the first one?

Facebook did not adopt Adaptive Cards so you can't use it over there. We do best effort to render as close as we could.

compulim avatar Jun 27 '18 18:06 compulim

@compulim button designed using hero card and below is the code

`var msg = new builder.Message(session) .attachments([ new builder.HeroCard(session) .title("Space Needle") .subtitle("The Space Needle is an observation tower in Seattle, Washington, a landmark of the Pacific Northwest, and an icon of Seattle.") .buttons([ builder.CardAction.imBack(session, "select:100", "Select"), builder.CardAction.imBack(session, "select:101", "Select1"), builder.CardAction.imBack(session, "select:102", "Select2"), builder.CardAction.imBack(session, "select:103", "Select3"), builder.CardAction.imBack(session, "select:104", "Select4") ]), ]);``

After count of three, button gets spilited in fb. Can you tell me how can i split buttons into column(2 or 3 in one row)?

pankajGODB avatar Jun 28 '18 04:06 pankajGODB

@pankajGODB see https://docs.botframework.com/en-us/channel-inspector/channels/Facebook?f=HeroCard&e=example1

danmarshall avatar Jun 28 '18 17:06 danmarshall

Closing due to inactivity

corinagum avatar Nov 29 '18 23:11 corinagum