2

i have a problem using adaptive card JSON into python web chat bot (BotFrameWork), i want to know how to customize values in the JSON element, these values are dynamic. I explain more i have to do a list of books information in one card, but title,author,etc... changes everytime. So how i can fill values dynamically? That's my json file

{
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.3",
"body": [
    {
        "type": "ColumnSet",
        "columns": [
            {
                "type": "Column",
                "width": "stretch",
                "items": [
                    {
                        "type": "TextBlock",
                        "text": "RISULTATI",
                        "horizontalAlignment": "center",
                        "spacing": "None",
                        "size": "Large",
                        "color": "Attention",
                        "wrap": true
                    }
                ]
            }
        ]
    },
    {
        "type": "ColumnSet",
        "separator": true,
        "spacing": "Medium",
        "columns": [
            {
                "type": "Column",
                "width": "stretch",
                "items": [
                    {
                        "type": "TextBlock",
                        "text": "Nome Libro e autore",
                        "isSubtle": true,
                        "weight": "Bolder",
                        "wrap": true
                    },
                    {
                        "type": "TextBlock",
                        "text": "Prezzo",
                        "spacing": "Small",
                        "wrap": true
                    },
                    {
                        "type": "TextBlock",
                        "text": "Disponibilità",
                        "spacing": "Small",
                        "wrap": true
                    },
                    {
                        "type": "TextBlock",
                        "text": "Link",
                        "spacing": "Small",
                        "wrap": true
                    }
                ]
            },
            {
                "type": "Column",
                "width": "auto",
                "items": [
                    {
                        "type": "TextBlock",
                        "text": "Genere",
                        "horizontalAlignment": "Right",
                        "isSubtle": true,
                        "weight": "Bolder",
                        "wrap": true
                    }   
                ]
            }
        ]
    },
    {
        "type": "ColumnSet",
        "spacing": "Medium",
        "separator": true,
        "columns": [
            {
                "type": "Column",
                "width": 1,
                "items": [
                    {
                        "type": "TextBlock",
                        "text": "Prezzo",
                        "spacing": "Small",
                        "wrap": true
                    },
                    {
                        "type": "TextBlock",
                        "text": "Disponibilità",
                        "spacing": "Small",
                        "wrap": true
                    },
                    {
                        "type": "TextBlock",
                        "text": "Link",
                        "spacing": "Small",
                        "wrap": true
                    }
                   
                ]
            }
          
        ]
    }
]

}

I have to fill the text values in items, how i should do this?

1 Answers1

0

The Adaptive Cards SDK doesn't have Python support, unfortunately, so you won't be able to make dynamic cards directly in your bot code. However, you can still use Adaptive Card Templating, so your cards can be somewhat dynamic, although it's limited to the data you include in the card.

So, you really have two options:

  1. Change from Python to .NET or JS, or
  2. Write your card JSON, load it in Python, and edit it dynamically in your code before attaching it to an activity. I go over that a bit in #3, here--it's in C#, but the same concept applies.
mdrichardson
  • 7,141
  • 1
  • 7
  • 21