Custom Slot extraction and validation fails using custom actions

Hi, thank you so much for responding to my topic. Indeed I’ve noticed those two mistakes but somehow it didn’t fix my other issue, so I did more documentation reading and research and found out that the custom slot extract actions are always run on the background to keep the slots updated.

Here’s the action server log after fixing the two mistakes (I added a print in all methods for debugging):

(venv) PS D:\chatbotTest> rasa run actions --debug D:\FinanceBot\venv\lib\site-packages\sanic_cors\extension.py:39: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead. SANIC_VERSION = LooseVersion(sanic_version) 2022-04-29 13:36:37 INFO rasa_sdk.endpoint - Starting action endpoint server… 2022-04-29 13:36:37 INFO rasa_sdk.executor - Registered function for ‘action_ask_brand’. 2022-04-29 13:36:37 INFO rasa_sdk.executor - Registered function for ‘action_ask_model’. 2022-04-29 13:36:37 INFO rasa_sdk.executor - Registered function for ‘validate_purchase_form’.
2022-04-29 13:36:37 INFO rasa_sdk.endpoint - Action endpoint is up and running on http://0.0.0.0:5055 2022-04-29 13:36:37 DEBUG rasa_sdk.utils - Using the default number of Sanic workers (1). 2022-04-29 13:37:14 DEBUG rasa_sdk.executor - Received request to run ‘action_ask_brand’ Ask brand 2022-04-29 13:37:14 DEBUG rasa_sdk.executor - Finished running ‘action_ask_brand’ 2022-04-29 13:37:19 DEBUG rasa_sdk.executor - Received request to run ‘validate_purchase_form’
Extract brand Extract model Validate brand Validate model 2022-04-29 13:37:19 DEBUG rasa_sdk.executor - Finished running ‘validate_purchase_form’ 2022-04-29 13:37:22 DEBUG rasa_sdk.executor - Received request to run ‘action_ask_model’ Ask model 2022-04-29 13:37:22 DEBUG rasa_sdk.executor - Finished running ‘action_ask_model’ 2022-04-29 13:37:42 DEBUG rasa_sdk.executor - Received request to run ‘validate_purchase_form’
Extract brand Extract model Validate brand Validate model 2022-04-29 13:37:42 DEBUG rasa_sdk.executor - Finished running ‘validate_purchase_form’ 2022-04-29 13:37:44 DEBUG rasa_sdk.executor - Received request to run ‘action_ask_model’ Ask model 2022-04-29 13:37:44 DEBUG rasa_sdk.executor - Finished running ‘action_ask_model’

I later found someone with the same issue, NoxDv on Github suggested to add a conditional statement in each extract method if tracker.slots[“requested_slot”] == “model” and it worked :+1:.

Here is the extract method for model after adding that conditional statement:

async def extract_model(
         self,
         dispatcher:CollectingDispatcher,
         tracker: Tracker,
         domain: DomainDict,
     ) -> Dict[Text, Any]:

     print("Extract model")
    print(tracker.slots["requested_slot"] == "model")
    if tracker.slots["requested_slot"] == "model":
        text_of_last_user_message = tracker.latest_message.get("text")
        model= text_of_last_user_message
    
        if model not in models:
            print(model)
            
            print(tracker.get_slot("model"))
            return {"model": None}
           
        print(tracker.get_slot("model"))
        return  {"model": model}
        
    print(tracker.get_slot("model")) 
    return {"model": tracker.get_slot("model")}

Thank you all for the help!