【问题标题】:Adaptive Cards and Microsoft Bot Framework: will only permit 'openUrl' action?Adaptive Cards 和 Microsoft Bot Framework:只允许“openUrl”操作吗?
【发布时间】:2019-11-26 11:20:43
【问题描述】:

编辑 2:以下架构(由同事提供)有效。我从 Microsoft 的示例中的架构中删除了引号,但这仍然不起作用。我不确定问题是什么。如果其他人想提供答案,我会保留这个问题,但我已经解决了。

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
                }
            ]
        }
    };

我正在尝试使用自适应卡片在我的 MS Bot 中制作表格。我从 MS 站点 (https://blog.botframework.com/2019/07/02/using-adaptive-cards-with-the-microsoft-bot-framework/) 获取了示例表单,但出现以下错误

错误似乎认为我的操作类型是Action.openUrl,但我在下面的代码中没有看到。非常感谢任何帮助。使用 Microsoft Bot Framework 3,节点 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);
    }

编辑:

似乎无论我设置什么动作,它都一直认为这是一个openUrl 动作。事实上,如果我将它设置为 openUrl 并给它一个 url 属性,它就可以正常工作。

我查看了这个页面 -- https://docs.microsoft.com/en-us/microsoftteams/platform/task-modules-and-cards/cards/cards-actions#adaptive-cards-actions -- 并按照那里的“带有 messageBack 操作的自适应卡”的说明进行操作,但它没有改变任何东西

"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\"}"
                }
            }
        }
    ]
}

【问题讨论】:

    标签: node.js botframework adaptive-cards


    【解决方案1】:

    你正在做的事情有很多问题。建议大家使用 Bot Builder v4 而不是 v3。您的同事解决的主要问题是您尝试使用 Adaptive Card 对象,就好像它是一个 Attachment 对象一样。

    您链接到的博文解释说自适应卡片必须遵循自适应卡片架构。 Adaptive Cards 架构中没有Action.messageBack。请继续参阅文档以获取更多信息。

    【讨论】:

    • 我正在一个大型框架中工作,他们正在迁移到 v.4,但目前我必须使用 v.3——不是我的选择......
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-12-18
    • 2023-03-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多