I integrated a sentiment analysis component into my chatbot. User messages are classified with a neutral, positive or negative sentiment provided as an entity. I am now thinking about ways to adjust the chatbot responses based on the extracted sentiment. I already implemented a custom action which cheers up the user if he is in a bad mood similar to the moodbot (rasa/examples/moodbot at master · RasaHQ/rasa · GitHub). However, I would prefer to make changes with more impact. I would suggest that the bot uses different styles of language based on the sentiment (e.g. adding emoticons based on the sentiment of the messages). What would be the best approach to do so?
what I meant is that you don’t need to use a Form to set a slot. This can also be achieved by using a custom action, e.g. like this:
class ActionCheckSentiment(Action):
def name(self) -> Text:
return "action_check_sentiment"
def extract_sentiment_from_tracker(self, tracker: Tracker) -> Dict:
"""Tries to check for present sentiment data. May affect the story."""
return tracker.sentiment # keep in mind that you need to use your implementation here
def run(self,
dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
sentiment = self.extract_sentiment_from_tracker(tracker=tracker)
slot_sets = []
slot_sets.append(SlotSet("sentiment", sentiment))
return slot_sets
Actually you are returning a SlotSet Event. This avoids having the overhead of a Form.
HI Julian , I would like to ask more the custom action part (btw I test on RASA 2.6 it works on the part using the experimental features )
Currently I using raspberry pi with RASA 1.10.26 ver , so I might need to use this approach using Cust Action for the extract_sentiment_from_tracker function at the return part what implementation I need to do here and also how do I use it for my stories , I think a example might help me better to understand . Thanks