sandeep2213
(Boyinapalli Sandeep Dora)
December 29, 2020, 4:44am
1
Rasa is not asking for extra slots. It is only asking the first one
my action file is:
class ValidateFormCreateCan(FormValidationAction):
def name(self) -> Text:
return 'validate_form_reg_can'
async def required_slots(
self,
slots_mapped_in_domain: List[Text],
dispatcher: "CollectingDispatcher",
tracker: "Tracker",
domain: "DomainDict",
) -> Optional[List[Text]]:
if tracker.get_slot("SAMEADDRESS") == "False":
print(tracker.get_slot("SAMEADDRESS"))
slots_mapped_in_domain = slots_mapped_in_domain + ['PERMANENTADDRESSSTATE'] + tn_state_slots
else:
print(tracker.get_slot("SAMEADDRESS"))
slots_mapped_in_domain = slots_mapped_in_domain + tn_state_slots
print(slots_mapped_in_domain)
return slots_mapped_in_domain
async def extract_PERMANENTADDRESSSTATES(
self,
dispatcher: "CollectingDispatcher",
tracker: "Tracker",
domain: "DomainDict",
) -> Dict[Text, Any]:
return {"PERMANENTADDRESSSTATE" : tracker.latest_message.get("text")}
domain file for forms is:
form_reg_can:
ADHAARCARDNUMBER:
- type: from_text
APPELLATION:
- type: from_text
NAME:
- type: from_text
FATHERNAME:
- type: from_text
MOTHERNAME:
- type: from_text
GENDER:
- type: from_text
DATEOFBIRTH:
- type: from_text
CURRENTADRESSDISTRICT:
- type: from_text
CURRENTADRESSTALUK:
- type: from_text
CURRENTREVENUEVILLAGE:
- type: from_text
CURRENTSTREETNAMEORNUMBER:
- type: from_text
CURRENTFLATORBUILDINGORDOORNUMBER:
- type: from_text
CURRENTBLOCKNAMEORNUMBER:
- type: from_text
SAMEADDRESS:
- type: from_text
# PERMANENTADDRESSSTATE:
# - type: from_text
# PERMANENTADRESSDISTRICT:
# - type: from_text
# PERMANENTADRESSTALUK:
# - type: from_text
# PERMANENTREVENUEVILLAGE:
# - type: from_text
# PERMANENTPINCODE:
# - type: from_text
# PERMANENTSTREETNAMEORNUMBER:
# - type: from_text
# PERMANENTFLATORBUILDINGORDOORNUMBER:
# - type: from_text
# PERMANENTBLOCKNAMEORNUMBER:
# - type: from_text
SECONDDOCUMENT:
- type: from_text
MARITALSTATUS:
- type: from_text
RELIGION:
- type: from_text
RELATIONSHIP:
- type: from_text
COMMUNITY:
- type: from_text
OCCUPATION:
- type: from_text
MOBILENO:
- type: from_text
EMAILID:
- type: from_text
OTP:
- type: from_text
CURRENTPINCODE:
- type: from_text
EDUCATIONALQUALIFICATION:
- type: from_text
LANDLINE:
- type: from_text
BANKNAME:
- type: from_text
ACCOUNTNUMBER:
- type: from_text
IFSCCODE:
- type: from_text
BRANCHNAME:
- type: from_text
# OTHERSTATEDISTRICT:
# - type: from_text
# OTHERSTATETALUK:
# - type: from_text
# OTHERSTATEVILLAGE:
# - type: from_text
alexyuwen
(Alex Yuwen)
December 29, 2020, 6:17am
2
The Rasa docs mention that for any action which extends FormValidationAction
, “you need to write functions named validate_<slot_name>
for every extracted slot.” (Forms ). I wonder if that would fix the problem. You would need to include something like this:
def validate_SLOT_NAME(self, slot_value: Any, dispatcher: CollectingDispatcher, tracker: Tracker, domain: DomainDict, ) -> Dict[Text, Any]:
return {"SLOT_NAME": slot_value}
for every slot where essentially no validation occurs.
sandeep2213
(Boyinapalli Sandeep Dora)
December 29, 2020, 6:35am
3
We had a decorator for that i think that is not a problem
alexyuwen
(Alex Yuwen)
December 29, 2020, 11:53pm
4
I see. When you say that Rasa is only asking for the first slot, do you mean that the form literally stops after the very first slot? Or is your problem that Rasa isn’t asking for PERMANENTADDRESSSTATE
after SAMEADDRESS
is set to False? Because if that’s the case, you would need to change the order of the last line of the if-block to something like this:
slots_mapped_in_domain = ['PERMANENTADDRESSSTATE'] + slots_mapped_in_domain + tn_state_slots
so that PERMANENTADDRESSSTATE
would be the next slot asked.
sandeep2213
(Boyinapalli Sandeep Dora)
December 30, 2020, 1:02am
5
No it is asking for permanent state and then stopping it is not asking for other things like th state or other state slots. I don’t know what is wrong with that
alexyuwen
(Alex Yuwen)
December 30, 2020, 1:15am
6
I think there may be a typo on this line:
async def extract_PERMANENTADDRESSSTATES(
Did you mean to add that extra ‘S’ at the end?
sandeep2213
(Boyinapalli Sandeep Dora)
December 30, 2020, 1:28am
7
No not like that it is asking properly only but I’m not getting the proper way to extract it. permanent address state is a button response. But no where in Rasa documentation they said method to extract from button response
alexyuwen
(Alex Yuwen)
December 30, 2020, 1:36am
8
Well the way to set slots from buttons would be something like this:
utter_ask_SLOT_NAME:
- text: "Please choose one."
buttons:
- title: "AL"
payload: '/inform{"PERMANENTADDRESSSTATE": "Alaska"}'
- title: "AZ"
payload: '/inform{"PERMANENTADDRESSSTATE": "Arizona"}'
...
And if you wanted to set buttons within a custom action or validation action check out the solution here: Buttons without text
sandeep2213
(Boyinapalli Sandeep Dora)
December 30, 2020, 1:48am
9
Ok Thank you for that I’ll try that one. But if we use this should we definitely write a extract method for that or just a response in domain file? and a small doubt what is /inform there is that an intent or …
alexyuwen
(Alex Yuwen)
December 30, 2020, 3:00am
10
Yes, it would be /intent_name
. I don’t think you’d need an extract method for your case.
sandeep2213
(Boyinapalli Sandeep Dora)
December 30, 2020, 3:12am
11
If you are free now can we join using GMeet please