Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/352.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 动态创建自适应卡bot框架azure_Python_Json_Azure_Botframework - Fatal编程技术网

Python 动态创建自适应卡bot框架azure

Python 动态创建自适应卡bot框架azure,python,json,azure,botframework,Python,Json,Azure,Botframework,我在将AdaptiveCardJSON用于python web聊天机器人(BotFrameWork)时遇到了一个问题,我想知道如何自定义JSON元素中的值,这些值是动态的。我解释得更多,我必须在一张卡片上列出图书信息,但标题、作者等。。。每次都会改变。那么如何动态地填充值呢? 这是我的json文件 { "$schema": "http://adaptivecards.io/schemas/adaptive-card.json", "type&qu

我在将AdaptiveCardJSON用于python web聊天机器人(BotFrameWork)时遇到了一个问题,我想知道如何自定义JSON元素中的值,这些值是动态的。我解释得更多,我必须在一张卡片上列出图书信息,但标题、作者等。。。每次都会改变。那么如何动态地填充值呢? 这是我的json文件

{
"$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
                    }
                   
                ]
            }
          
        ]
    }
]
}

我必须在项目中填写文本值,我应该如何做?

没有Python支持,不幸的是,您将无法在bot代码中直接制作动态卡。但是,您仍然可以使用,因此您的卡可以是动态的,尽管它仅限于卡中包含的数据

因此,您确实有两种选择:

  • 从Python更改为.NET或JS,或
  • 编写卡JSON,在Python中加载,并在将其附加到活动之前在代码中动态编辑它。我在#3中讨论了一下,它在C中,但同样的概念也适用