new to the rasa framework. I've been trying to make a simple bot that would simply recognize the intent of me providing my name and then rasa responding with a phrase including my name. The problem is that it does seem to recognize the intent but if the name I give it is not included in one of the examples then the response just includes none instead of my name (meaning the slot is empty). I thought its because of the lack of examples but I added more than 20. It would only fill that slot if the name provided was one of the names provided in the examples.
Furthermore, I can't seem to use rules. I was under the assumption that on a technical level I can just use rules for one-off questions such as providing the name and the bot responding hello, name. I can only get responses if it was a story.
rules.yml:
# ask name confirmation
- rule: ask name confirmation
steps:
- intent: inform_name
- action: utter_greet_with_name
# respond with name
- rule: respond with name
steps:
- action: utter_respond_with_name
# respond without name
- rule: respond without name
condition:
- slot_was_set:
- name: null
steps:
- action: utter_respond_without_name
nlu.yml:
- intent: inform_name
examples: |
- I'm [Sarah](name).
- Hi, my name is [Chris](name).
- You can call me [Alex](name).
stories.yml:
stories:
- story: path 1
steps:
- intent: greet
- action: utter_greet
- intent: inform_name
- action: utter_greet_with_name
- intent: ask_name
- action: utter_respond_with_name
- story: path 2
steps:
- intent: greet
- action: utter_greet
- intent: ask_name
- action: utter_respond_without_name
part of domain.yml
entities:
- name
# Define the 'name' slot with the 'from_text' mapping
slots:
name:
type: text
influence_conversation: true
mappings:
- type: from_entity
entity: name
Thank you!
Generally, based on your entity category, you can benefit from different entity extractors. You can add Duckling, SpaCy, and CRF to your Rasa pipeline. Here I suggest going with SpacyEntityExtractor
as it has a pre-trained model good for recognizing Names, Companies, etc.
Here you need to first install Spacy lib.
python -m pip install -U rasa[spacy]
python -m spacy download en_core_web_lg
Then you can set up your pipeline in config.yml
and add the following lines to deploy the entity extractor.
name: "SpacyNLP"
# language model to load
model: "en_core_web_lg"
and
- name: "SpacyEntityExtractor"
dimensions: ["PERSON"]
For a better explanation of how to set up your config, pls refer to Rasa docs