Hello, I’m trying to build a chatbot that can detect sentiment and give responses based on that. I found conditional response variations meet my requirements very well, and I set the condition in domain.yml like this:
utter_based_on_sentiment:
- condition:
- type: slot
name: sentiment
value: pos
text: "Great, I'm very happy for you! 😄"
- condition:
- type: slot
name: sentiment
value: neg
text: "Oh! Very sorry to hear that.
But when I try to add another text under pos condition to enhance the diversity of responses, I got this problem :
The configuration for policies was chosen automatically. It was written into the config file at 'config.yml'.
YamlSyntaxException: Failed to read '/Users/baoyue/Desktop/m2/emo_bot/domain.yml'. while constructing a mapping
in "/Users/baoyue/Desktop/m2/emo_bot/domain.yml", line 71, column 5:
- condition:
^ (line: 71)
found duplicate key "text" with value "Glad to hear it!" (original value: "Great, I'm very happy for you! 😄")
in "/Users/baoyue/Desktop/m2/emo_bot/domain.yml", line 76, column 5:
text: "Glad to hear it!"
^ (line: 76)
You can use https://yamlchecker.com/ to validate the YAML syntax of your file.
It seems conditional response variations can only take one text for a condition, what should I do?
@JenniferTanH Please check the indentation of your code and in last text you forgot to close the " " after that, please ref this doc link : Responses and yes, you can use another text, please check this doc example, how we can add -text:
utter_based_on_sentiment:
- condition:
- type: slot
name: sentiment
value: pos
text: "Great, I'm very happy for you! 😄"
- condition:
- type: slot
name: sentiment
value: neg
text: "Oh! Very sorry to hear that."
OR
- condition:
- type: slot
name: sentiment
value: neg
text: "Oh! Very sorry to hear that."
- text: " Aww, so sorry to hear that "
PS: If you are using bool slot, I would recommend to check the doc Responses
Thanks, because I want my bot to be more human-like, since it can detect sentiment, it is very dummy to always give the same response. Do i need to use custom actions to do this?