Ask particular action for fixed no of time

Hi All,

I want to know that is there any method so that I can ask a particular action from user to 3 times. If user give any value which is in intent or not it should send that particular action. I tried by adding stories but it didn’t work.

e.g. Currently, It is working like: User: I want to play. Bot: utter_ask_game_name User: Hi Bot: utter_greet User: hello Bot: utter_greet User: Hi Bot: utter_greet

and I want something like: User: I want to play. Bot: utter_ask_game_name User: Hi Bot: utter_ask_game_name User: hello Bot: utter_ask_game_name User: Hi Bot: utter_greet

P.S. Here Hi is an intent with entity greet.

1 Like

That is a tricky one, I guess you can do that with a form - @Ghostvv that should work right?

yes, I think it is possible with the form. One of the solutions could be something among the lines: create two slots counter and asked_3_times with the later to be form required slot. Customize request_next_slot method. Each time the form is called you update the counter in validate method, and if the counter is equal to 3 set asked_3_times to True, then the form will finish, and other policies would pick up later predictions

Thanks @Ghostvv @tmbo for response but when using form_action I am getting another problem: I am filling slots from Custom actions and after that to verify if bot have filled all the slots I am using FormAction but because all the slots are already filled FormAction does not work. It shows TypeError: 'NoneType' object is not iterable in action but when I use FormAction directly without filling those slots from other custom action it works but as I said earlier I want to fill slots from custom action first(because of Internal API calling) not directly from FormAction(can’t make dynamic buttons i.e. can’t call API in domain.yml). Can you help me with this?

can you post debug logs when your error appears

Thanx @Ghostvv for your help I have resolved that problem but actually, I have to show dynamic buttons(from API calling) which I can’t do in domain.yml file and form_action uses actions from domain.yml templates, not from custom_action which creates another problem for using Form Action.
Is there any method so that I can resolve this issue?

you need to implement the logic from your custom actions inside FormAction

from rasa_core.events import UserUtteranceReverted

intent =tracker.latest_message[‘intent’].get(‘name’) if intent == “hi”: return[UserUtteranceReverted()] else: return[]

Thanx @ashukrishna100 for answer but It will ask user same action again and again but I have to ask same action for max 3 times in-case previous one is invalid.

Hi Vladimir, I am facing similar issue. I am using ‘count’ as a slot to update the counter. I am not able to update the counter. I tried SlotSet in validation_count but, it is not getting updated to the slot. I think I have to return [SlotSet(…)] to update the count slot. But, I am unable to return this in validate_count method as this is expecting a dict to be returned. Please help.

validate_count method will be called if your requested_slot is count. Depending on what you want, you should update count slot when the form is called

Hi @Ghostvv, I also want to deactivate the form if

  1. user gives incorrect or unexpected value for the slot called ID. when count =1
  2. user gives incorrect or unexpected vale for the slot called Password for 2 times (count =2). Please help me with this. Here, FYI the form is requesting for the ID slot first and then PIN Thanks

please take a look at our docs: Forms on how to validate user input