【问题标题】:How to force one bot.on runs before another bot.on如何强制一个 bot.on 在另一个 bot.on 之前运行
【发布时间】:2018-09-23 02:55:26
【问题描述】:

我创建了一个 MS azure 聊天机器人,并使用 bot.on(.....); 这是我的示例代码。

bot.on("event", function (event) {
    if (event.name === "greeting") {
        locale = event.value;
        console.log("event runs");
        eventTimestamp = event.timestamp;
    }
});

bot.on("conversationUpdate", function (message) {
 .............    
});

我想让事件在对话更新之前运行......有没有办法在 azure bot 框架中做到这一点。 谢谢。

【问题讨论】:

  • 您不能,因为 Bot Framework 通道连接器需要在发送 conversationUpdate 类型的活动之前路由实际的 event 活动,该活动是在与用户发起对话时发送的.您可以做的不是使用conversationUpdate 类型的活动,而是只挂钩event 类型的活动。您能否提供有关您的用例的更多详细信息?

标签: node.js azure botframework azure-bot-service


【解决方案1】:

您可以使用recieve 中间件。它将在conversationUpdate之前运行

bot.use({
    recieve: function(event, next){
        locale = event.textLocale; // you can use textLocale
        console.log("event runs");
        eventTimestamp = event.timestamp; // this event also provides timestamp
        next(); // don't forget to call next
    }
});

【讨论】:

    猜你喜欢
    • 2023-03-22
    • 1970-01-01
    • 2021-10-08
    • 1970-01-01
    • 2021-04-23
    • 1970-01-01
    • 1970-01-01
    • 2023-03-05
    • 2022-01-21
    相关资源
    最近更新 更多