How to take an input from the user and save it in a slot

If i am taking a feedback from the user , how to take the input without evaluating it as an intent as the feedback would be different every time, and save it in a slot

Hi @Elssa. I think you are looking for entity extraction. Let me know if you have more questions :slight_smile:

No not looking for entity extractions, I have to store the user input, this input can be anything, so i can’t define it in intents for it ,but i have to save the input and display the thank you message

@Elssa Hmm. You are still going to need an intent with examples of what is acceptable input. Otherwise, how will the assistant know when a user input falls under this case vs. one of your other intents. I think you are saying you want to grab the entire user message? You can do this in a custom action by calling I believe tracker.latest_message.get('text') or a form with from_text

yes , I have used tracker.latest_message.get(‘text’) that is fine, I just had the doubt regarding intents

Did you eventually find a solution?

1 Like

Also interested in a solution for this issue.

1 Like

I think the solution here is using forms. I recommend to read the doc since it’s a bit specific. To my humble opinion Rasa is missing some easy to use catch-all action out-of-the-box.

But in general,

  • You make a form in your domain.yml:
slots:
  my_slot:
    type: text
    mappings:
    - type: custom

forms:
  my_form:
    required_slots:
    - my_slot
  • Create a custom form validation action. Apart from the forms doc, you can read about it here or check out rasa forum questions like this one.
from rasa_sdk.forms import FormValidationAction

class ValidateMyForm(FormValidationAction):
    def name(self) -> Text:
        return "validate_my_form"

    def extract_my_slot(self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict[Text, Any]):
        # Code here
        return {"my_slot_name": something}

    def validate_my_slot(self, value: Text, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict[Text, Any]):
    # Code here
  • After that you can read stories/rules like that:
- story: my_story
  steps:
  - intent: my_intent
  - action: utter_something
  - action: my_form_name
  - active_loop: my_form_name
  - slot_was_set:
    - requested_slot: my_slot_name
  - active_loop: null
  - action: some_other_action