Action.Submit自适应卡不使用Input.Text Python SDK

时间:2018-05-31 12:50:31

标签: botframework azure-bot-service

我正在尝试使用Bot Builder v4 Python SDK的自适应卡。我正在尝试使用Input.text字段收集用户的反馈,然后使用Action.submit

{
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.0",
"body": [                           
],
"actions": [{
        "type": "Action.ShowCard",
        "title": "Want to provide feedback",
        "card": {
            "type": "AdaptiveCard",
            "actions": [
        {
            "type": "Action.Submit",
            "data": "Yes, it was helpful",
            "title": "Yes"
        },
        {
            "type": "Action.Submit",
            "data": "No, it wasn't helpful",
            "title": "No"
        },
        {
            "type": "Action.Submit",
            "data": "Start Over",
            "title": "Start Over"
        },
        {
            "type": "Action.Submit",
            "data": "Exit",
            "title": "Exit"
        },{
        "type": "Action.ShowCard",
        "title": "Comment",
        "card": {
            "type": "AdaptiveCard",
            "body": [
                {
                    "type": "Input.Text",
                    "id": "comment",
                    "isMultiline": true,
                    "placeholder": "Enter your comment"
                }
            ],
            "actions": [
                {
                    "type": "Action.Submit",
                    "title": "OK"
                }
            ]
        }
    }
        ]
        }
    }
]}

这在visualizer上运作良好。当我写一些注释并单击确定时,这适用于可视化工具,但在实践中不起作用。它引发了502错误。

见下面的截图 Sample screenshot

我正在使用Bot Build v4 SDK for Python并在Web Chat上进行测试。似乎自适应卡方面没有问题,我想这与Python SDK有关。关于错误可能位置的任何指针?

1 个答案:

答案 0 :(得分:0)

请尝试使用以下代码段进行快速测试:

def __create_reply_activity(request_activity):
        return Activity(
            type=ActivityTypes.message,
            channel_id=request_activity.channel_id,
            conversation=request_activity.conversation,
            recipient=request_activity.from_property,
            from_property=request_activity.recipient,
            attachments=[Attachment(
                content_type='application/vnd.microsoft.card.adaptive',
                content={
                    "type": "AdaptiveCard",
                    "body": [
                    ],
                    "actions": [{
                            "type": "Action.ShowCard",
                            "title": "Want to provide feedback",
                            "card": {
                                "type": "AdaptiveCard",
                                "actions": [
                                    {
                                        "type": "Action.Submit",
                                        "data": "Yes, it was helpful",
                                        "title": "Yes"
                                    },
                                    {
                                        "type": "Action.Submit",
                                        "data": "No, it wasn't helpful",
                                        "title": "No"
                                    },
                                    {
                                        "type": "Action.Submit",
                                        "data": "Start Over",
                                        "title": "Start Over"
                                    },
                                    {
                                        "type": "Action.Submit",
                                        "data": "Exit",
                                        "title": "Exit"
                                    },
                                    {
                                        "type": "Action.ShowCard",
                                        "title": "Comment",
                                        "card": {
                                            "type": "AdaptiveCard",
                                            "body": [
                                                {
                                                    "type": "Input.Text",
                                                    "id": "comment",
                                                    "isMultiline": "true",
                                                    "placeholder": "Enter your comment"
                                                }
                                            ],
                                            "actions": [
                                                {
                                                    "type": "Action.Submit",
                                                    "title": "OK"
                                                }
                                            ]
                                        }
                                    }
                                ]
                            }
                    }],
                },
                )],
            service_url=request_activity.service_url)

Adding an adaptive card to bot framework with python

上有一个详细的解释