Apply Sentiment Analysis through a Slot

Hi , i need to apply sentiment analysis to a slot called feedback from getting user provided text through the form and the bot will need to utter different type of message based on the sentiment values (pos, neu , neg) through custom action e.g through the dispatcher.utter_message(template=“utter_based_on_sentiment”)

can anyone provide me with reference or guide me how can i do it ? I found a reference from post but i not sure how to implment which post by : JulianGerhard

Thanks

Can anyone help me on this ? I had already apply Sentiment component to my chatbot , currently my implementation was

slots:
  sentiment:
    type: categorical
    values:
      - positive
      - neutral
      - negative
responses:
  utter_based_on_sentiment:
    - condition:
        - type: slot
          name: sentiment
          value: positive
      text: "Hey, {name}. Nice to see you again! How are you?"

    - condition:
        - type: slot
          name: sentiment
          value: neutral
      text: "Hey, {name}. How are you?"

Above using conditional response variations .

actions.py

Class ActionSubmitFeedback(Action):

    def name(self) -> Text:

        return "action_submit_feedback"

  

    def run(

        self,

        dispatcher: CollectingDispatcher,

        tracker: Tracker,

        domain: Dict[Text, Any],

    ) -> List[Dict]:

        sentiment = tracker.get_slot("sentiment")

        dispatcher.utter_message(template="utter_based_on_sentiment")

i have a form in rules.yml which flow to ActionSubmitFeedback Action Class when form is filled with a feedback slot to save as slot from user text . How can i change my code in action to let my chatbot utterance different messge based on the feedback slot .

Have you seen our new blogpost on conditional response variation?

Hi koaning yes , i did and also implemented but didn’t show here , i think i have i solved my problem which i asked. Current now i faced another challenge is to obtain the slot value the sentiment that was predicted by my custom component and i not sure is this the right way to do it and i tested by running the action to pass to utterance but it cache my old response >.< i does not know why

actions.py
sentiment = tracker.get_slot("sentiment")

dispatcher.utter_message(template="utter_display_sentiment", customer_sentiment = sentiment) 

domain.yml
utter_display_sentiment:

  - text: Thanks {customer_sentiment}

but it cache my old response

Could you clarify what you mean with this statement? What is happening in the conversation and what did you expect instead?

can you please share your nlu file?