imBack有效载荷恢复瀑布

时间:2018-03-22 17:48:33

标签: node.js botframework

我的聊天机器人上有一个按钮,一旦被点击, 它应该恢复对话框到瀑布对话框的下一步。

我找不到可以执行此操作的有效负载值,我尝试action?resumeaction?next

[
    (session, args, next) => {
        let msg = new builder.Message().text('welcome')
            .attachments([new builder.HeroCard(session)
            .buttons([builder.CardAction.imBack(session, 'next', 'next')])])
        session.send(msg);
    }, (session, args, next) => { 
        //I'm here if button clicked - if not, handle somewhere else 
    }
]

1 个答案:

答案 0 :(得分:1)

我猜你想用英雄牌来提示某事,即等待用户点击英雄卡上的某个按钮。这是代码示例

bot.dialog("/", function(session) {
  session.beginDialog("test");
});

bot.dialog("test", [
  function(session) {
    // create a hero card
    let msg = new builder.Message()
      .text("welcome")
      .attachments([
        new builder.HeroCard(session).buttons([
          builder.CardAction.imBack(session, "next", "next")
        ])
      ]);
    // prompt user using hero card
    builder.Prompts.text(session, msg);
  },
  function(session, result) {
    // if user clicked some button, then do someting useful
    if (result.response === "next") {
      // do something, like calling another dialog
    } else { // user didn't clicked button, so prompt the hero card again
      session.send("please click a button");
      session.replaceDialog("test");
    }
  }
]);