microsoft / BotFramework-Emulator

A desktop application that allows users to locally test and debug chat bots built with the Bot Framework SDK.
https://aka.ms/botemulator
MIT License
1.81k stars 753 forks source link

I cant see my adaptive card on the Bot builder emulator, it appears as blank. #2337

Closed syedjalal12 closed 2 years ago

syedjalal12 commented 2 years ago

I'm using Python Bot Builder framework and I'm testing it on the emulator. Now I know that my adaptive card JSON file is perfect because it show's all the data as I desired on both VisualStudio Code and https://adaptivecards.io/designer/. However when I run the emulator my adaptive is completely blank.

Now the code I'm using for my adaptive card is:

    `def adaptive_flight_card_attachment(self):
            JSONFileName = 'QuickAdaptiveJSONfile.json'
            file_path = "AdaptiveFlightCardFile"

            if os.path.exists(file_path):
                    files_in_dir = os.listdir(file_path)
                            if JSONFileName in files_in_dir:
                                    file_path = os.getcwd()+f'/{file_path}'+f'/{JSONFileName}'
                                    with open(file_path, "r+", encoding="unicode_escape") as in_file:
                                            card = json.load(in_file)
                                            return Attachment( content_type="application/vnd.microsoft.card.adaptive", content=card )      `

Then I run this using:

    `FlightDetailCard = self.adaptive_flight_card_attachment()
    response = MessageFactory.attachment(FlightDetailCard)
    await turn_context.send_activity(response)`

Somewhere in here I'm making a mistake and I can't seem to understand where. So can anyone please help me out here?

syedjalal12 commented 2 years ago

This how the adaptive card appears: Bot Framework Emulator 19_11_2021 2_28_18 pm

And this is how it should be: QuickAdaptiveJSONfile json - Python Behave BDD - Visual Studio Code 19_11_2021 2_30_12 pm

syedjalal12 commented 2 years ago

This is my generated Adaptive card JSOn file

{ "type": "AdaptiveCard", "$schema": "http://adaptivecards.io/schemas/adaptive-card.json", "version": "1.5", "body": [ { "type": "Container", "items": [ { "type": "TextBlock", "text": "Departing DETAILS", "wrap": true, "color": "Accent", "weight": "Bolder", "size": "Large", "horizontalAlignment": "Center" } ] }, { "type": "Container", "items": [ { "type": "ColumnSet", "columns": [ { "type": "Column", "width": "stretch", "items": [ { "type": "TextBlock", "text": "Doha", "wrap": true, "color": "Good", "size": "Medium", "weight": "Bolder", "fontType": "Monospace", "horizontalAlignment": "Left" } ], "verticalContentAlignment": "Center", "id": "DepartingFlightDepartingCity" }, { "type": "Column", "width": "50px", "items": [ { "type": "Image", "url": "FlightPlane.png", "size": "Small", "horizontalAlignment": "Center", "id": "DepartingPlaneImg" } ] }, { "type": "Column", "width": "stretch", "items": [ { "type": "TextBlock", "wrap": true, "text": "Barcelona", "fontType": "Monospace", "weight": "Bolder", "color": "Good", "size": "Medium", "horizontalAlignment": "Right" } ], "id": "DepartingFlightArrivalCity", "verticalContentAlignment": "Center" } ] } ], "id": "DepartingFlightCities", "isVisible": true }, { "type": "Container", "items": [ { "type": "ColumnSet", "columns": [ { "type": "Column", "width": "stretch", "items": [ { "type": "TextBlock", "text": "Departing Airport: Hamad International Airport", "wrap": true, "fontType": "Monospace", "size": "Small", "weight": "Bolder", "color": "Light" } ], "id": "DepartingFlightDepartingAirport" }, { "type": "Column", "width": "stretch", "items": [ { "type": "TextBlock", "text": "Arrival Airport: Josep Tarradellas Barcelona-El Prat Airport", "wrap": true, "fontType": "Monospace", "size": "Small", "weight": "Bolder", "color": "Light", "horizontalAlignment": "Right" } ], "id": "DepartingFlightArrivalAirport" } ] } ], "verticalContentAlignment": "Center", "id": "DepartingAirports", "isVisible": true }, { "type": "Container", "items": [ { "type": "ColumnSet", "columns": [ { "type": "Column", "width": "stretch", "items": [ { "type": "TextBlock", "text": "Take off: 7:45 AM", "wrap": true, "weight": "Bolder", "color": "Accent", "fontType": "Monospace" } ], "id": "DepartingFlightDepartingTime" }, { "type": "Column", "width": "stretch", "items": [ { "type": "TextBlock", "text": "Landing: 12:50 PM", "wrap": true, "horizontalAlignment": "Right", "style": "default", "weight": "Bolder", "color": "Accent", "fontType": "Monospace" } ], "id": "DepartingFlightArrivalTime" } ] } ], "id": "DepartingFlightTime", "isVisible": true }, { "type": "Container", "items": [ { "type": "TextBlock", "wrap": true, "text": "Total flight time: 7 hr 5 min.", "horizontalAlignment": "Center", "fontType": "Monospace", "size": "Medium", "weight": "Bolder" } ], "id": "DepartingFlightTotalTime", "isVisible": true }, { "type": "Container", "items": [ { "type": "TextBlock", "wrap": true, "text": "Total layovers: 5000", "size": "Medium", "fontType": "Monospace", "weight": "Bolder", "id": "TotalLayovers" }, { "type": "Container", "items": [ { "type": "ColumnSet", "columns": [ { "type": "Column", "width": "auto", "items": [ { "type": "Image", "url": "https://static.thenounproject.com/png/3184838-200.png", "size": "Medium", "id": "LayoverImg" } ], "verticalContentAlignment": "Top" }, { "type": "Column", "width": "stretch", "items": [ { "type": "TextBlock", "text": "Layover city: L A Y RETURN C I T Y ", "wrap": true, "fontType": "Monospace", "size": "Default", "weight": "Bolder", "id": "LayoverCity" }, { "type": "TextBlock", "text": "Layover airport: L A Y RETURN A I R P O R T", "fontType": "Monospace", "weight": "Bolder", "wrap": true, "id": "LayoverAirport" }, { "type": "TextBlock", "text": "Layover time: L A Y RETURN T I M E", "wrap": true, "fontType": "Monospace", "weight": "Bolder", "id": "LayoverTime" } ] } ] } ], "style": "attention", "id": "LayoverDetails" } ], "style": "warning", "id": "DepartingLayoverContainer", "isVisible": false }, { "type": "Container", "items": [ { "type": "TextBlock", "wrap": true, "text": "RETURN DETAILS", "horizontalAlignment": "Center", "size": "Large", "color": "Accent", "weight": "Bolder" } ] }, { "type": "Container", "items": [ { "type": "ColumnSet", "columns": [ { "type": "Column", "width": "stretch", "items": [ { "type": "TextBlock", "text": "Barcelona", "wrap": true, "fontType": "Monospace", "size": "Medium", "weight": "Bolder", "color": "Good" } ], "verticalContentAlignment": "Center", "id": "ReturnFlightDepartingCity" }, { "type": "Column", "width": "50px", "items": [ { "type": "Image", "url": "FlightPlane.png", "horizontalAlignment": "Center", "size": "Small", "width": "-1px" } ] }, { "type": "Column", "width": "stretch", "items": [ { "type": "TextBlock", "wrap": true, "text": "Doha", "horizontalAlignment": "Right", "fontType": "Monospace", "size": "Medium", "weight": "Bolder", "color": "Good" } ], "verticalContentAlignment": "Center", "id": "ReturnFlightArrivalCity" } ] } ], "id": "ReturnFlightCities", "isVisible": true }, { "type": "Container", "items": [ { "type": "ColumnSet", "columns": [ { "type": "Column", "width": "stretch", "items": [ { "type": "TextBlock", "text": "Departing Airport: Josep Tarradellas Barcelona-El Prat Airport", "wrap": true, "fontType": "Monospace", "size": "Small", "weight": "Bolder", "color": "Light" } ], "id": "ReturnFlightDepartingAirport" }, { "type": "Column", "width": "stretch", "items": [ { "type": "TextBlock", "text": "Arrival Airport: Hamad International Airport", "wrap": true, "horizontalAlignment": "Right", "fontType": "Monospace", "size": "Small", "weight": "Bolder", "color": "Light" } ], "id": "ReturnFlightArrivalAirport" } ] } ], "id": "ReturnAirports", "isVisible": true }, { "type": "Container", "items": [ { "type": "ColumnSet", "columns": [ { "type": "Column", "width": "stretch", "items": [ { "type": "TextBlock", "text": "Take off: 8:40 AM", "wrap": true, "fontType": "Monospace", "weight": "Bolder", "color": "Accent" } ], "id": "ReturnFlightDepartingTime" }, { "type": "Column", "width": "stretch", "items": [ { "type": "TextBlock", "text": "Landing: 4:55 PM", "wrap": true, "horizontalAlignment": "Right", "fontType": "Monospace", "weight": "Bolder", "color": "Accent" } ], "id": "ReturnFlightArrivalTime" } ] } ], "id": "ReturnFlightTime", "isVisible": true }, { "type": "Container", "items": [ { "type": "TextBlock", "text": "Total flight time: 6 hr 15 min.", "wrap": true, "weight": "Bolder", "fontType": "Monospace", "size": "Medium", "horizontalAlignment": "Center" } ], "id": "ReturnFlightTotalTime", "isVisible": true }, { "type": "Container", "items": [ { "type": "TextBlock", "wrap": true, "text": "Total layovers: 5000", "size": "Medium", "fontType": "Monospace", "weight": "Bolder", "id": "TotalLayovers" }, { "type": "Container", "items": [ { "type": "ColumnSet", "columns": [ { "type": "Column", "width": "auto", "items": [ { "type": "Image", "url": "https://static.thenounproject.com/png/3184838-200.png", "size": "Medium", "id": "LayoverImg" } ], "verticalContentAlignment": "Top" }, { "type": "Column", "width": "stretch", "items": [ { "type": "TextBlock", "text": "Layover city: L A Y RETURN C I T Y ", "wrap": true, "fontType": "Monospace", "size": "Default", "weight": "Bolder", "id": "LayoverCity" }, { "type": "TextBlock", "text": "Layover airport: L A Y RETURN A I R P O R T", "fontType": "Monospace", "weight": "Bolder", "wrap": true, "id": "LayoverAirport" }, { "type": "TextBlock", "text": "Layover time: L A Y RETURN T I M E", "wrap": true, "fontType": "Monospace", "weight": "Bolder", "id": "LayoverTime" } ] } ] } ], "style": "attention", "id": "LayoverDetails" } ], "style": "warning", "id": "ContainerReturnLayover", "isVisible": false }, { "type": "Container", "items": [ { "type": "Container", "items": [ { "type": "ColumnSet", "columns": [ { "type": "Column", "width": "auto", "items": [ { "type": "TextBlock", "wrap": true, "text": "TOTAL FARE:", "fontType": "Monospace", "size": "Large", "color": "Accent", "style": "heading" } ], "verticalContentAlignment": "Center" }, { "type": "Column", "width": "stretch", "items": [ { "type": "TextBlock", "text": "PKR 192,037", "wrap": true, "style": "heading", "fontType": "Monospace", "size": "ExtraLarge", "color": "Good", "horizontalAlignment": "Right" } ], "id": "CostOfFlight" } ] } ] } ], "id": "TotalFlightCost", "isVisible": true }, { "type": "Container", "items": [ { "type": "ActionSet", "actions": [ { "type": "Action.OpenUrl", "style": "positive", "title": "VIEW DETAILS", "url": "https://www.google.com/travel/flights/booking?tfs=CBwQAhpJagwIAxIIL20vMGYyeXcSCjIwMjEtMTItMDlyDAgDEggvbS8wMWY2MiIfCgNET0gSCjIwMjEtMTItMDkaA0JDTioCUVIyAzE0NRpJagwIAxIIL20vMDFmNjISCjIwMjEtMTItMTNyDAgDEggvbS8wZjJ5dyIfCgNCQ04SCjIwMjEtMTItMTMaA0RPSCoCUVIyAzEzOHABggELCP___________wFAAUgBmAEB&tfu=CmxDalJJYjNCT2FHbEtPVGxOYWxsQlRGRnVjV2RDUnkwdExTMHRMUzB0TFhkeloyZ3hNRUZCUVVGQlIwZGpNMEp2UWpSVU1FRkJFZ1ZSVWpFek9Cb0xDS2JjQ3hBQUdnTlFTMUk0SEhEMjFBWT0SBggFEAAYAA" } ] } ], "id": "FlightURL", "isVisible": true } ] }

rvinothrajendran commented 2 years ago

Issue in the json file , fix this issue and check again

image

syedjalal12 commented 2 years ago

Issue resolver. Thank you @rvinothrajendran