Adding Middleware in Bot Framework Composer V2

Viewed 240

I want to add a Middleware in a Bot Framework Composer project but I can't find any documentation on how to do it.

How would one go about adding a simple Middleware, let's say a Middleware that logs all the exchanged messages to console, in a bot created with Bot Framework Composer v2.1.1?

2 Answers

you have to mention the middleware component name in "configure -> settings.json" file.
ex:

"components": [
  {
    "name": "BotComposerMiddlewareComponent"
  }
],


Note : BotComposerMiddlewareComponent is a middleware component name.

find the sample here how to write the custom middleware for bot composer

  1. Create a class file
  2. Inherit this interface - Microsoft.Bot.Builder.IMiddleware
  3. Implement OnTurnAsync Method like below code sample
  4. You will have access to context, Activity and other stuffs you do in bot framework library implementations

I have wrote a detailed article on creating middleware for Bot Framework Composer here: https://lkgforit.com/implementing-middleware-in-bot-framework-composer

Related