未触发自适应卡片操作

Adaptive card action not triggered

我有一个名为 "form search" 的对话框,它有一个自适应卡片。当我单击提交按钮时,控件不会转到下一个流程,而是以错误结束。但是如果使用英雄卡按钮点击触发下一个 flow.what 可能是问题。

session.message不包含值,也不触发下一个流程。

bot.dialog("/FormSearch",[

    function(session,args, next) {

        var card = {
            contentType: "application/vnd.microsoft.card.adaptive",
            content:{
                "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
                "type": "AdaptiveCard",
                "version": "1.0",
                "body": [
                    {
                        "type": "ColumnSet",
                        "columns": [
                            {
                                "type": "Column",
                                "width": 2,
                                "items": [
                                    {
                                        "type": "TextBlock",
                                        "text": "Tell us about yourself",
                                        "weight": "bolder",
                                        "size": "medium"
                                    },
                                    {
                                        "type": "TextBlock",
                                        "text": "Your name",
                                        "wrap": true
                                    },
                                    {
                                        "type": "Input.Text",
                                        "id": "myName",
                                        "placeholder": "Last, First"
                                    },
                                    {
                                        "type": "TextBlock",
                                        "text": "Your email",
                                        "wrap": true
                                    },
                                    {
                                        "type": "Input.Text",
                                        "id": "myEmail",
                                        "placeholder": "youremail@example.com",
                                        "style": "email"
                                    },
                                    {
                                        "type": "TextBlock",
                                        "text": "Phone Number"
                                    },
                                    {
                                        "type": "Input.Text",
                                        "id": "myTel",
                                        "placeholder": "xxx.xxx.xxxx",
                                        "style": "tel"
                                    }
                                ]
                            },
                            {
                                "type": "Column",
                                "width": 1,
                                "items": [
                                    {
                                        "type": "Image",
                                        "url": "https://upload.wikimedia.org/wikipedia/commons/b/b2/Diver_Silhouette%2C_Great_Barrier_Reef.jpg",
                                        "size": "auto"
                                    }
                                ]
                            }
                        ]
                    }
                ],
                "actions": [
                    {
                        "type": "Action.Submit",
                        "title": "Submit"
                    }
                ]
            }
        }

    // var card = new builder.HeroCard(session)
    // .title('card title')
    // .subtitle('subtitle')
    // .images([builder.CardImage.create(session, 'http://oobrien.com/wordpress/wp-content/uploads/2016/07/googlemaps_july2016.jpg')])
    // .buttons([
    //     builder.CardAction.openUrl(session, 'https://www.google.com', "Navigate"),
    //     builder.CardAction.postBack(session, 'select', "select")
    // ]);



         var msg = new builder.Message(session).addAttachment(card);
        builder.Prompts.text(session, 'Fill in the below form'); 
        session.send(msg);


    },

    function(session,results) {
        console.log('next flow ____________');
        if (session.message && session.message.value) {
            console.log('A Card Submit Action obj was received');
           session.send('form submitted');
        }

    }


]);

触发了错误消息

Error message screenshot

请参阅文档 here regarding adaptive cards in the botbuilder-webchat 存储库。

具体来说:

The data property of the action may be a string or it may be an object. A string is passed back to your bot as a Bot Builder SDK imBack activity, and an object is passed as a postBack activity. Activities with imBack appear in the chat stream as a user-entered reply. The postBack activities are not displayed.

至于您的代码,请尝试将此代码块移动到您的对话框函数中:

    if (session.message && session.message.value) {
        console.log('A Card Submit Action obj was received');
       session.send('form submitted');
    }

还有一个很好的 node example here 用于处理提交操作。