Error while executing custom form action

Hey everyone I am getting an error when I try to execute my ActionForm

This is my error message:

ERROR rasa_sdk.endpoint - Exception on /webhook [POST]

Traceback (most recent call last): File “/home/vphrase/Desktop/chatbot/chat_bot/lib/python3.6/site-packages/flask/app.py”, line 2446, in wsgi_app response = self.full_dispatch_request() File “/home/vphrase/Desktop/chatbot/chat_bot/lib/python3.6/site-packages/flask/app.py”, line 1951, in full_dispatch_request rv = self.handle_user_exception(e) File “/home/vphrase/Desktop/chatbot/chat_bot/lib/python3.6/site-packages/flask_cors/extension.py”, line 161, in wrapped_function return cors_after_request(app.make_response(f(*args, **kwargs))) File “/home/vphrase/Desktop/chatbot/chat_bot/lib/python3.6/site-packages/flask/app.py”, line 1820, in handle_user_exception reraise(exc_type, exc_value, tb) File “/home/vphrase/Desktop/chatbot/chat_bot/lib/python3.6/site-packages/flask/_compat.py”, line 39, in reraise raise value File “/home/vphrase/Desktop/chatbot/chat_bot/lib/python3.6/site-packages/flask/app.py”, line 1949, in full_dispatch_request rv = self.dispatch_request() File “/home/vphrase/Desktop/chatbot/chat_bot/lib/python3.6/site-packages/flask/app.py”, line 1935, in dispatch_request return self.view_functionsrule.endpoint File “/home/vphrase/Desktop/chatbot/chat_bot/lib/python3.6/site-packages/flask_cors/decorator.py”, line 128, in wrapped_function resp = make_response(f(*args, **kwargs)) File “/home/vphrase/Desktop/chatbot/chat_bot/lib/python3.6/site-packages/rasa_sdk/endpoint.py”, line 59, in webhook response = executor.run(action_call) File “/home/vphrase/Desktop/chatbot/chat_bot/lib/python3.6/site-packages/rasa_sdk/executor.py”, line 245, in run events = action(dispatcher, tracker, domain) File “/home/vphrase/Desktop/chatbot/chat_bot/lib/python3.6/site-packages/rasa_sdk/forms.py”, line 528, in run events = self._activate_if_required(dispatcher, tracker, domain) File “/home/vphrase/Desktop/chatbot/chat_bot/lib/python3.6/site-packages/rasa_sdk/forms.py”, line 474, in _activate_if_required for slot_name in self.required_slots(tracker):

TypeError: required_slots() takes 1 positional argument but 2 were given

My Custom FormAction:

`class ExplorazorForm(FormAction):

     def name(self):
          return 'explorazor_form'

     def required_slots(tracker):
	"""A list of required slots that the form has to fill"""
	if tracker.latest_message['intent'].get('name') == "get_email":
		return ['email', 'target_col', 'dimension']
	else:
		return ['target_col', 'dimension']

     def submit(self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict[Text, Any]) -> List[Dict]:
	"""Define what the form has to do after all required slots are filled"""
	# utter submit template
	dispatcher.utter_template("utter_submit", tracker)
	return []

`

Please help me out here.

Hi @nikhilcss97! Can you show me what your stories look like?

Hey @tyd thanks for replying

Actually I am trying to generate stories through rasa interactive. As of now I have very basic stories:

`## Generated Story -277470545592324679

  • goodbye
    • utter_goodbye
    • action_restart

Generated Story -277470545592325679

  • goodbye
    • utter_goodbye
    • action_restart
    • action_restart

Generated Story -277470545592327679

  • goodbye
    • utter_goodbye
    • action_restart

Generated Story -277470545592328679

  • goodbye
    • utter_goodbye
    • action_restart

Generated Story -277470545592329679

  • goodbye
    • utter_goodbye
    • action_restart

Generated Story -277470545592323679

  • goodbye
    • utter_goodbye
    • action_restart

Generated Story 5012937932990255788

  • greet
    • utter_greet
  • goodbye
    • action_restart

Happy Path

  • greet
    • utter_greet
  • market_share
    • explorazor_form
    • form{“name”: “explorazor_form”}
    • form{“name”: null}
    • utter_slots_values
  • affirm
    • action_display_card_market_share
  • send_email
    • explorazor_form
    • form{“name”: “explorazor_form”}
    • form{“name”: null}
    • action_send_email
  • goodbye
    • action_restart `

I typed the last story myself

Hey @nikhilcss97, try adding @static_method above your required slots like so:

@static_method
def required_slots(tracker):
	"""A list of required slots that the form has to fill"""
	if tracker.latest_message['intent'].get('name') == "get_email":
		return ['email', 'target_col', 'dimension']
	else:
		return ['target_col', 'dimension']

Thanks a lot @erohmensing adding @staticmethod worked. The interpreter was expecting a “self” as a parameter hence was giving me the error “2 parameters…”.

Yep, you’re right about it expecting self! Glad that fixed your problem. :slight_smile: