Integrating hate speech detection on chatbot

Hello everyone, I am relatively new to Rasa so I would need your help. the project I am currently working on is hatespeech detection on chatbot interactions. For the time being I have created a custom action that connects the chatbot with my colab notebook where the hatespeech is recognized. So whichever message I write on the chatbot the bot answers whether its hate speech or not. In order to do so I created just one story for the bot to train on which includes the action write away. I would like to create any scenario like the concert bot or a weather bot for the user to participate , but I would like the bot to constantly search for hate speech in every single message of the user while following the scenario and if hatespeech is found , stop the interaction. Could someone guide me ? Thank you all in advance!

You should look at creating a custom component to do this. There’s a blog post that walks through creating a sentiment analysis component that will be helpful but note that this post follows the old component format (pre 3.0). There’s also a gist here.

thank you vey much , i will look into it . seems a little bit advanced/intimidating the custom component but i will have a look. I was trying to do it with slots and the current custom action I have, is there a way you believe that I can do it like this ?.

Every story/rule would need to call your custom action to evaluate the utterance.

you mean by some kind of a loop in every story/rule? In the case of the custom component can i just call the custom action at the end of the pipeline in some way ? So that it can check every time the user writes sth? Is there an if/else statement I can use in the pipeline?

Creating a component is the best way to do this.

I was pointing out that you could try dropping an action_score_hatespeech after every intent in your stories and rules but I doubt that would work well.