How to set slot value for form validation

Hi Team, i am struggling how to set extras slot value for form validation, i have extras slot name “rephrase”, want to set value for this slit my overall idea, i only want validate 2 times, after that it will stop asking form value again, please help me

def validate_tech_keyword(
    self,
    value: Text,
    dispatcher: CollectingDispatcher,
    tracker: Tracker,
    domain: Dict[Text, Any],
) -> Dict[Text, Any]:
    """Validate tech_keyword value."""
    
    rephrase = tracker.get_slot('rephrase')
    print("rephrase status " + str(rephrase))
    print(response.text)

    if response.text == "[]":
        if(rephrase == "askForRephrase"):
    
            dispatcher.utter_button_message("Sorry! cannot find anything related to your request.", buttons)
        else:
            # validation failed, set this slot to None, meaning the # user will be asked for the slot again
            dispatcher.utter_message("Sorry! We cannot find anything related to your request. Can you type a different keyword instead ?")
            return [SlotSet("rephrase", "askForRephrase"),{"tech_keyword": None}]
    else:
        # validation succeeded, set the value of the "cuisine" slot to value
        return {"tech_keyword": value}

can some one help me :(, need me provide more information please let me know

Any luck? Having the same issue

Hello Folks @iforno

I had a similar issue, I wanted to fill a categorial slot with information to indicate a result from a financial transaction (success, fail), so I used a custom action to set the slot’s value.

It might help. Greetings.

1 Like

But how are you calling it? While in a validation_form method the return is just {“form_being_validated”: value}

I wanted to set another slot IF the validation is not ok, so did @iforno if I understood right.

def validate_form(self):
      if valid:
        return {"slot": value}
    else:
        return [SlotSet("anotherSlot", "value"),{"slot": None}]
1 Like