BotFramework 中的建议操作与键盘?

SuggestedActions vs Keyboard in BotFramework?

BotFramework 中的 SuggestedActions 和 Keyboard class 有什么区别?

我目前正在尝试 运行 一个瀑布,我在其中提出问题,用户选择一个选项,然后我跳转到瀑布中的下一步。我已经实现了带有建议操作功能的按钮

const msg = new builder.Message(session)
    .text("Which pair?  \nExample: ETH BTC")
    .suggestedActions(
    builder.SuggestedActions.create(
        session, [
            builder.CardAction.postBack(session, "BTC USD", "BTC USD"),
            builder.CardAction.postBack(session, "ETH USD", "ETH USD"),
            builder.CardAction.postBack(session, "ETH BTC", "ETH BTC"),
            builder.CardAction.postBack(session, "XRP BTC", "XRP BTC"),
            builder.CardAction.postBack(session, "ZEC USD", "ZEC USD")
        ]
    ));
session.send(msg);

键盘也可以这样做class

const msg = new builder.Message(session)
    .text("Which pair?  \nExample: ETH BTC")
    .addAttachment(new builder.Keyboard(session)
        .buttons([
            builder.CardAction.postBack(session, "BTC USD", "BTC USD"),
            builder.CardAction.postBack(session, "ETH USD", "ETH USD"),
            builder.CardAction.postBack(session, "ETH BTC", "ETH BTC"),
            builder.CardAction.postBack(session, "XRP BTC", "XRP BTC"),
            builder.CardAction.postBack(session, "ZEC USD", "ZEC USD")
        ]).toAttachment()
    )
session.send(msg);

如何在下一个瀑布流步骤中捕获来自此按钮的响应,或者我应该改为使用提示。还有这个和键盘有什么区别class

SuggestedActionsKeyboard 的替代品(例如 in C# 你会看到它们与键盘相关的东西被标记为过时)。

要捕获响应,您可以将建议的操作作为提示选择的一部分发送,如 feature-suggestedActions 示例所示。

bot.dialog('/', [
    function (session) {

        var msg = new builder.Message(session)
            .text("Hi! What is your favorite color?")
            .suggestedActions(
                builder.SuggestedActions.create(
                    session,[
                        builder.CardAction.imBack(session, "green", "green"),
                        builder.CardAction.imBack(session, "blue", "blue"),
                        builder.CardAction.imBack(session, "red", "red")
                    ]
                )
            );
        builder.Prompts.choice(session, msg, ["green", "blue", "red"]);
    },
    function(session, results) {
        session.send('I like ' +  results.response.entity + ' too!');
    }
]);