0
votes

EDIT 2: The following schema (provided by a colleague) works. I removed the quotation marks from the schema in the examples from Microsoft, but that still didn't work. I'm not sure what the issue is. I leave the question open in case someone else wants to provide an answer, but I've got it working.

const card = {
        contentType: 'application/vnd.microsoft.card.adaptive',
        content: {
            $schema: 'http://adaptivecards.io/schemas/adaptive-card.json',
            type: 'AdaptiveCard',
            version: '1.0',

            {
            type: 'Input.Text',
            placeholder: 'Name',
            style: 'text',
            maxLength: 50,
            id: 'defaultInput'
            },
            actions: [
                {
                    type: 'Action.Submit',
                    title: 'Siguiente',
                    data: {} // will be populated with form input values
                }
            ]
        }
    };

I'm trying to make a form in my MS Bot using Adaptive Cards. I took the sample form from the MS site (https://blog.botframework.com/2019/07/02/using-adaptive-cards-with-the-microsoft-bot-framework/) but get the following error

enter image description here

The error seems to be thinking that my action type is Action.openUrl but I don't see that in my code, which is below. Any help much appreciated. Using Microsoft Bot Framework 3, Node 12.13.0.

  function askPolicyNumber(session) {
        const card = {
            '$schema': 'https://adaptivecards.io/schemas/adaptive-card.json',
            'type': 'AdaptiveCard',
            'version': '1.1',
            'body': [
                {
                    'type': 'Input.Text',
                    'id': 'id_text'
                },
                {
                    'type': 'Input.Number',
                    'id': 'id_number'
                }
            ],
            'actions': [
                {
                    'type': 'Action.messageBack',
                    'title': 'Submit',
                    'data': {
                        'prop1': true,
                        'prop2': []
                    }
                }
            ]
        };
        const msg = new builder.Message(session).attachments([card]);
        return session.send(msg);
    }

EDIT:

It seems that no matter what I set the action to it keeps thinking it's an openUrl action. In fact, if I set it to openUrl and give it a url property, it works fine.

I looked at this page -- https://docs.microsoft.com/en-us/microsoftteams/platform/task-modules-and-cards/cards/cards-actions#adaptive-cards-actions -- and followed the instructions there for 'Adaptive Cards with messageBack action', but it didn't change anything

"actions": [
        {
            "type": "Action.Submit",
            "title": "Click me for messageBack",
            "data": {
                "msteams": {
                    "type": "messageBack",
                    "displayText": "I clicked this button",
                    "text": "text to bots",
                    "value": "{\"bfKey\": \"bfVal\", \"conflictKey\": \"from value\"}"
                }
            }
        }
    ]
}
1

1 Answers

1
votes

There are a lot of problems with what you're doing. It is recommended that everyone use Bot Builder v4 instead of v3. The main problem that your colleague solved was that you were trying to use an Adaptive Card object as though it was an Attachment object.

The blog post you linked to explains that Adaptive Cards must follow the Adaptive Cards schema. There is no Action.messageBack in the Adaptive Cards schema. Please continue referring to the documentation for more information.