botbuilder-community-dotnet icon indicating copy to clipboard operation
botbuilder-community-dotnet copied to clipboard

Convert SentimentAnalysisMiddleware to the package

Open arafattehsin opened this issue 4 years ago • 3 comments

Hi @garypretty - assigning it myself for this one.

The idea is to convert these middleware(s), starting with Sentiment Analysis Middleware to the package one by one and then we can work on the samples / docs for these.

arafattehsin avatar May 10 '21 17:05 arafattehsin

Hey Arafat.

A good place for you to look is the LivePerson component. Here you can see that you register the middleware in your component by registering as a singleton and then it will be automatically picked up and added to the pipeline. https://github.com/BotBuilderCommunity/botbuilder-community-dotnet/blob/8ee1370c551304f7f16e008cea1daab001973a44/libraries/Bot.Builder.Community.Components.Handoff.LivePerson/LivePersonHandoffComponent.cs#L13

I would recommend though that you add some form of setting to enable / disable the middleware, using the IConfiguration that gets passed in. You can then advise the user to add the appropriate setting(s), as I do here for LP https://github.com/BotBuilderCommunity/botbuilder-community-dotnet/tree/feature/packages-preview/libraries/Bot.Builder.Community.Components.Handoff.LivePerson.

e.g. you might have the following setting.

"Bot.Builder.Community.Components.Middleware.SentimentAnalysis": { "Enabled": true }

and then use the value to wrap everything in the OnTurn event in your middleware.

Does that help / make sense?

garypretty avatar May 11 '21 08:05 garypretty

I am merging the components to the develop branch in the next couple of hours, so you might want to wait until then to create your branch.

garypretty avatar May 11 '21 08:05 garypretty

Thanks @garypretty for the detailed explanation. Yes, it does make sense and I will aim for this one! 👍

arafattehsin avatar May 11 '21 10:05 arafattehsin