I have implemented a middleware in sdk V4 Bot to intercept each message between bot & user and log that custom mongo Db. I am trying to implement similar concept for Bot built using SDK v4. Looks like I can use following piece of code to add a middleware but, not sure how to differentiate message between bot to user & user to bot.
V3 bot code
bot.use({
botbuilder: function (session, next) {
logUserConversation(session)
next()
},
send: function (event, next) {
logBotsConversation(event)
next()
}
})
V4 bot code for Middleware
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.
});