Hi everyone can someone help me with a question? I am working with forms and slots, and I want to save the text entered by the user in a slot of the form, how can I do it?
with this in the slotmapping
return { “your_entity”: self.from_text(intent=“your_intent”) }
thanks for your answer!.
but being data of an address? does it have to be added in my intities?
you can give me an example?
thanks for your time
I need to save a text written by the user when filling the form. being this the address of your home, example: mallorca # 1219
and I can’t have all the directions in one intent
yes just make an intent inform like this:
intent:inform
[el casique #45] (address)
[lomas de oriente #89] (address)
[pueblita #45] (address)
[hidalgo #78] (address)
with more examples of course
in your domian file you need:
intents:
- inform
- "all:your_others_intents"
entities:
- address
- "all:your_others_entities"
slots:
address:
type: unfeaturized
"all_your_others_entities"
responses:
utter_ask_address:
- text: "What is your address??"
forms:
- your_form_name
in your actions.py
class RegisterAddress(FormAction):
def name(self):
return "your_form_name"
@staticmethod
def required_slots(tracker: Tracker) -> List[Text]:
"""A list of required slots that the form has to fill"""
list_slots = ["address"]
return list_slots
def slot_mappings(self) -> Dict[Text, Union[Dict, List[Dict[Text, Any]]]]:
"""A dictionary to map required slots to
- an extracted entity
- intent: value pairs
- a whole message
or a list of them, where a first match will be picked"""
return {
"address": self.from_text(intent="inform"),
}
def submit(self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict[Text, Any],) -> List[Dict]:
address = tracker.get_slot('address')
dispatcher.utter_message(f" \
address: {address}\n ")
return []
thank you very much for your help.
Currently I have it configured like this, but seeing that there are millions of streets in my city, it would be something too difficult to handle, you can get the intent of an API right?
adding that each street has approximately 200 possible house numbers
I don’t sure about it, but why do you want to have all the streets of your city in rasa??
that’s why I need to add to the rasa slot without validating the information (intent), only the message prior to the time of filling the form
you don’t need to put all of the existent address just need to put some real example and rasa must learn to detect an address even if this address is not in the examples. check this I think is what you need
the part of Entities Roles and Groups
what I was looking for !!!
thanks for your help (Y)