【发布时间】:2019-01-17 02:04:37
【问题描述】:
我在 sdk V4 Bot 中实现了一个中间件,以拦截 bot 和用户之间的每条消息并记录该自定义 mongo Db。我正在尝试为使用 SDK v4 构建的 Bot 实现类似的概念。看起来我可以使用以下代码添加中间件,但不知道如何区分机器人到用户和用户到机器人之间的消息。
V3 机器人代码
bot.use({
botbuilder: function (session, next) {
logUserConversation(session)
next()
},
send: function (event, next) {
logBotsConversation(event)
next()
}
})
中间件的 V4 机器人代码
botAdapter.use(async (turnContext, next) => {
// How to find which messages/activity object is from user to bot
await next();
// How to find which messages/activity object is from bot to user.
});
【问题讨论】:
标签: node.js botframework middleware microsoft-cognitive