BotFramework中的SuggestedActions和Keyboard类之间有什么区别?
我正在尝试运行一个瀑布,我提出一个问题,用户选择一个选项,然后我跳到瀑布的下一步。我已经使用建议的操作功能实现了按钮
gimme_a_shout_when_finished = TRUE
if (gimme_a_shout_when_finished){
library(jsonlite)
library(RPushbullet)
my_phone_id = "xxx...myphoneid...xxx"
my_PB_apikey = "xxx...myapikey...xxx"
pbPost(type = "note", title = "my tile", body = "my body",
apikey = my_PB_apikey, devices = my_phone_id, verbose = FALSE,
debug = FALSE)
}
键盘类
也是如此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);
如何在下一个瀑布步骤中捕获此按钮的响应,或者我应该切换到使用提示。这和键盘类有什么区别
答案 0 :(得分:1)
SuggestedActions
替代了Keyboard
(例如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!');
}
]);