ValidationAction for slot validations giving Import error

Hi I’m trying to use slot validations with ValidationAction but getting error ImportError: cannot import name ‘ValidationAction’ from ‘rasa_sdk’ while executing the below.

from rasa_sdk import ValidationAction

Can someone help on how to resolve this error. I’m trying to do this referring to Slot Validation Actions

Also can you give me an example of how to use slot validations without forms and with forms.

@ramyanarwa I guess it should be

For Rasa 2.x: from rasa_sdk import Tracker, FormValidationAction

For Rasa 3.x from rasa_sdk.forms import ValidationAction

can you please share the rasa version ? I’m not sure for the second one as I not started yet working on rasa 3.

Tip: See the both documents for Form Validations and how to import the validation.

I hope this will help you.

@nik202

Rasa Version : 2.8.14 Minimum Compatible Version: 2.8.9 Rasa SDK Version : 2.8.3 Rasa X Version : 0.39.3 Python Version : 3.8.8

Can we not validate slot without forms in 2.x?

How can we configure forms? It is asking to give in a dictionary format.

@nik202

When I don’t give required_slots, it’s giving me below error:

FutureWarning: The definition of slot mappings in your form should always be preceded by the keyword required_slots. The lack of this keyword will be deprecated in Rasa Open Source 3.0.0. Please see Forms for more information.

when I give required_slots, it’s giving me:

UserWarning: Loading domain from ‘domain.yml’ failed. Using empty domain. Error: ‘The contents of form ‘required_slots’ were specified as ‘<class ‘list’>’. They need to be specified as dictionary. Please see Forms for more information.’

@ramyanarwa your original post is related to import error? Is the above suggested solution helped you to solve the issue?

The validation concept is only related to Forms.

Please visit this Rasa Github Repo: GitHub - RasaHQ/rasa-2.x-form-examples: This repository contains a few simple projects with forms. and see the mentioned examples and code how we are using Slots, Actions, Forms, and Validations. You can even refer the Rasa Youtube channel (do always check the versions now)

This is question not related to the original post @ramyanarwa.

Please ref the above repo link and rasa doc for how to use the required_slots in the forms. Forms

You need to get to know how we mentioned the Form in the domain.yml, please check this link: Forms

Tip: I’d highly recommend you to see the rasa doc for form in detail and also see some related Forms video tutorials from the rasa channel. Good Luck!

@nik202

I have referred to the rasa docs and videos as well when I give similar to rasa docs it gives me the error to specify it as dictionary which I’m not able to find anywhere in docs nor in any of the videos.

Is this because I’m not using the latest version? But I changed the versions because of the compatibility issues for rasa x. I’m not sure on how to proceed with this.

@ramyanarwa please confirm me that your import validation action issue is sorted?

This I’m able to import but unable to use forms because of the issue I have explained earlier.

@ramyanarwa share your code so that we can see the issue?