I have the following issue: I’m working on a bot that asks the incoming user for first name and last name and storing provided values (two of them, one for the first name and one for the last name) into memory slots. When a user starts a session, he is asked for a first name fist, and normally what he would do is to type only the first name, meaning only one word. As a next step, he is asked for the last name, and normally he would react with typing one word only for his last name. How to implement this with Rasa, having in mind that there is no way to distinguish intents for entering the first name and the last name with handling one word only?
Hi @striki-ai,
I’m having a similar use case of collecting first name, last names and a 10-digit number from the user. Please let me know if you found a way to implement this.
After some research I found that it is impossible to distinguish intents for enterin first and last name by providing only one word. You can use lookup list or file, but you’ll never catch all the possible names. Therefore, the only sollution I found is to use Form as custom action where I’m interceptng all the user’s input while the form is active. Then, in Python code, I’m taking a look at the required slots, and if some is empty, I’m filling it. This runs until the form is active, i.e. submit method is executed.
Hey @striki-ai. I did the following way. As you said, yes, it’s hard to distinguish first and last names with separate intents.
We can have a common intent called inform and also a common enity for both called name. Also, we can still have 2 seperate slots first_name and last_name. We can extract the names in the form using slot mappings.
## intent:inform
- My first name is [James](name)
- my firstname is [Leota](name)
- My last name is [James](name)
- my lastname is [Spectre](name)
- Ok, it is [Minna](name)
- Its [Donette](name)
- It is [Abel](name)
- [Josephine](name)
- [Lenna](name)
- [Mitsue](name)
- [Sage](name)
- [Kris](name)
- [Kiley](name)
- [Graciela](name)
def slot_mappings(self) -> Dict[Text, Union[Dict, List[Dict]]]:
"""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 {
"first_name": [
self.from_entity(entity="name"),
self.from_text(intent="inform"),
],
"last_name": [
self.from_entity(entity="name"),
self.from_text(intent="inform"),
],
}