机器人对话框操作按钮问题 node.js

Bot Dialog Action button issue node.js

我正在尝试使用 Internet 上的一些示例通过 Microsoft Bot Framework 为 MS Teams 创建机器人。

我创建了带有按钮的用户名片"See Report"

function userCard(session, connector, name, workingStatus, TeamsID) {

    var card = new builder.HeroCard(session)
        .title(name)
        .subtitle(workingStatus.toString())
        .buttons([
            builder.CardAction.dialogAction(session, 'userReport', TeamsID, 'See Report')
        ]);
    return card;
}

卡片显示没有任何问题。当我按下按钮时,它应该触发新对话框

//Begins the userReport dialog if the button on the userCard is pressed
bot.beginDialogAction('userReport', '/userReport');

当我在 Bot Framework Emulator 中测试时,此功能完美运行。 在 MS Teams 中,它不会触发 userReport 对话框,而是转到主对话框(发送消息时使用的对话框)。以至于这个按钮根本不起作用。

你能告诉我应该 adjusted/added 什么才能使这个按钮在 MS Teams 中工作吗?

提前致谢!

谢天谢地,您才刚刚开始。看起来您正在使用严重过时的 Bot Framework V3。你绝对应该切换到 V4.

Teams 有其自身的额外技巧。我建议尝试并梳理每个示例:

然后通读Adaptive Cards blog post

基本上,自适应卡的响应会在 activity.value 中返回,因此在 onTurn() 中,您需要使用 if 语句来观看 activity.value用于当用户单击 "See Report" 时在自适应卡中发送的值。然后,根据需要使用 beginDialogdialog.run() 来启动对话。