0

当我们使用 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.

我对自适应卡的操作是:

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

所以问题是我如何处理这些确定和取消按钮?我应该添加另一个对话框吗?如果是这样, triggerAction 应该是什么?

4

1 回答 1

0

设置机器人时,请使用如下默认处理程序:

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

有关完整的工作示例,请查看:BotBuilder-Samples/Node/cards-AdaptiveCards

于 2017-07-07T16:52:19.490 回答