简体   繁体   English

如何使用LUIS处理自适应卡上的Action.submit

[英]How to handle the Action.submit on an adaptive card with LUIS

How do we do the handle Action.submit when we use the LUIS recognizer in our bot using MS BotFramework? 当我们使用MS BotFramework在我们的机器人中使用LUIS识别器时,如何处理Action.submit?

var recognizer = new builder.LuisRecognizer(config.LUIS_MODEL_URL);
bot.recognizer(recognizer);

bot.dialog('toolAccess', [
    function (session,args,next) {

           const msg = new builder.Message(session)
                      .addAttachment({
            //adaptive card body here with Action.submit buttons...
           });
           session.send(msg);
    }
]).triggerAction({ matches : 'toolAccess'});
//toolAccess is an intent in my LUIS app.

My actions for the adaptive card are: 我对自适应卡的操作是:

"actions": [
                {
                    "type": "Action.Submit",
                    "data": {
                            "type": "okProfileSelection"
                    },
                    "title": "OK"
                },
                {
                    "type": "Action.Submit",
                    "data": {
                            "type": "cancelProfileSelection"
                    },
                    "title": "Cancel"
                }
            ]

So the question is how do I handle these OK and Cancel buttons? 所以问题是如何处理这些“确定”和“取消”按钮? Should I add another dialog? 我应该添加另一个对话框吗? If so, what should the triggerAction be? 如果是这样,triggerAction应该是什么?

When you setup your bot, use a default handler like this: 设置机器人时,请使用如下默认处理程序:

var bot = new builder.UniversalBot(connector, function (session) {

    if (session.message && session.message.value) {
        // A Card's Submit Action obj was received
        processSubmitAction(session, session.message.value);
        return;
    }

    // Display Welcome card with Hotels and Flights search options
    // load Adaptive Card from JSON file
    var card = require('./card-hotels-flights-search.json');

    // send the card with form 
    var msg = new builder.Message(session).addAttachment(card);
    session.send(msg);
});

For a complete working example check out: BotBuilder-Samples/Node/cards-AdaptiveCards 有关完整的工作示例,请查看: BotBuilder-Samples / Node / cards-AdaptiveCards

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM