0
votes

I am trying the adaptive cards with the Bot Builder v4 Python SDK. I am trying to gather feedback from the user using the Input.text field and then the 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"
                }
            ]
        }
    }
        ]
        }
    }
]}

This is working well on the visualizer. When I write some comments and and click on OK, this works on the visualizer but does not work in practice. It raises a 502 error.

See below screenshot Sample screenshot

I'm using the Bot Build v4 SDK for Python and testing this on Web Chat. It seems there is no issue on the Adaptive Card side of this, I suppose this has something to do with the Python SDK. Any pointers as to where the error might be ?

1

1 Answers

0
votes

Please try following code snippet for quick test:

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)

And there is a detailed explain at Adding an adaptive card to bot framework with python