microsoft / BotFramework-Services

Microsoft Bot Framework Services
Creative Commons Attribution 4.0 International
38 stars 11 forks source link

Error: Malformed adaptive card #311

Closed pannerselvam-yaltech closed 3 years ago

pannerselvam-yaltech commented 3 years ago

I am trying to display customers list in MS Teams. My Adaptive card will shown in Bot composer and Developer web chat also, But when i host my app in Azure and connect my channel as MS Teams, it's show error message as "The bot encountered an error or bug" ,"To continue to run this bot, please fix the bot source code." And in console "name: 'DialogContextError', message: 'Malformed adaptive card'". Please help me to show this card. Adaptive card view: image

Adaptive card code:

To learn more Adaptive Cards format, read the documentation at https://docs.microsoft.com/en-us/adaptive-cards/getting-started/bots

{
  "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
  "version": "1.2",
  "type": "AdaptiveCard",
  "body": [
        {
            "type": "TextBlock",
            "text": "${item.name}",
            "separator": true,
            "maxLines": 1,
            "weight": "Bolder",
            "color": "Good",
            "id": "2"
        },
        {
            "type": "TextBlock",
            "text": "${item.address1_line1} ${item.address1_line2},${item.address1_city}",
            "wrap": true,
            "size": "Small",
            "weight": "Bolder",
            "id": "3"
        },
        {
            "type": "TextBlock",
            "text": "${item.emailaddress1}",
            "wrap": true,
            "color": "Dark",
            "id": "4"
        },
        {
            "type": "ColumnSet",
            "columns": [
                {
                    "type": "Column",
                    "width": "160px",
                    "verticalContentAlignment": "Center",
                    "items": [
                        {
                            "type": "ActionSet",
                            "actions": [
                                {
                                    "type": "Action.OpenUrl",
                                    "title": "${item.telephone1}",
                                    "iconUrl": "https://thumbs.dreamstime.com/z/phone-receiver-symbol-7983393.jpg",
                                    "url": "https://www.google.com",
                                    "id": "8"
                                }
                            ],
                            "id": "7"
                        }
                    ],
                    "id": "6"
                },
                {
                    "type": "Column",
                    "width": "stretch",
                    "horizontalAlignment": "Center",
                    "backgroundImage": {
                        "horizontalAlignment": "Center"
                    },
                    "items": [
                        {
                            "type": "ActionSet",
                            "actions": [
                                {
                                    "type": "Action.OpenUrl",
                                    "title": "Service History",
                                    "iconUrl": "https://yaltechglobal.com/UncleDavey/files/serviceHistoryIcon.jpg",
                                    "url": "https://www.google.com",
                                    "id": "11"
                                }
                            ],
                            "horizontalAlignment": "Center",
                            "id": "10"
                        }
                    ],
                    "id": "9"
                }
            ],
            "style": "default",
            "id": "5"
        }
    ]
}
stevkan commented 3 years ago

It looks like your adaptive card isn't structured correctly or there is something wrong on the adaptive cards side. When pasting your JSON in the Designer, if I put values into the Sample Data Editor, all the adaptive card properties acquire the values except for telephone1.

This suggests the issue is not in the BotFramework but instead either your JSON isn't structured correctly or in the AC SDK/service cannot read the value as it should.

pannerselvam-yaltech commented 3 years ago

However, I added Main container in card. and get proper response in Teams. Thanks all guys.

{ "type": "AdaptiveCard", "$schema": "http://adaptivecards.io/schemas/adaptive-card.json", "version": "1.2", "body": [ { "type": "Container", "items": [ { "type": "TextBlock", "text": "${item.name}", "wrap": true, "weight": "Bolder", "color": "Good", "separator": true, "spacing": "None" }, { "type": "TextBlock", "text": "${item.address1_line1} ${item.address1_line2},${item.address1_city}", "wrap": true, "size": "Small", "weight": "Bolder", "spacing": "None" }, { "type": "TextBlock", "text": "${item.emailaddress1}", "wrap": true, "color": "Accent", "spacing": "None" }, { "type": "ColumnSet", "columns": [ { "type": "Column", "width": "stretch", "items": [ { "type": "ActionSet", "actions": [ { "type": "Action.OpenUrl", "title": "${item.telephone1}", "url": "https://www.google.com", "iconUrl": "https://thumbs.dreamstime.com/z/phone-receiver-symbol-7983393.jpg" } ], "spacing": "None" } ] }, { "type": "Column", "width": "stretch", "items": [ { "type": "ActionSet", "actions": [ { "type": "Action.OpenUrl", "title": "Service History", "url": "https://www.google.com", "iconUrl": "https://yaltechglobal.com/UD/files/serviceHistoryIcon.jpg" } ], "spacing": "None" } ] } ], "spacing": "None" } ] } ] }