3

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?

Stefan Alexandru
  • 563
  • 1
  • 5
  • 18

2 Answers2

2

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

Vinoth Rajendran
  • 1,141
  • 1
  • 9
  • 13
0
  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://www.lkgforit.com/2022/10/implementing-middleware-in-bot.html

Sanjeevi Subramani
  • 501
  • 1
  • 5
  • 16