3

我有一个名为“表单搜索”的对话框,它有一个自适应卡。当我单击提交按钮时,控件不会进入下一个流程,而是以错误结束。但是如果使用英雄卡,按钮点击会触发下一个流程。可能是什么问题。

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');
        }

    }


]);

触发错误消息

错误信息截图

4

1 回答 1

1

请参阅此处有关botbuilder-webchat 存储库中自适应卡的文档。

具体来说:

动作的data属性可以是字符串,也可以是对象。字符串作为 Bot Builder SDK 活动传递回您的机器人imBack,对象作为postBack活动传递。活动imBack作为用户输入的回复出现在聊天流中。postBack活动不显示。

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

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

这里还有一个很好的节点示例来处理提交操作。

于 2018-04-03T20:47:49.810 回答