FormValidationAction method header produces NameError

I am trying to define custom slot mappings by writing a FormValidationAction (as described in the docs here: shorturl.at/bitS5). However, when I run rasa actions I get NameError: name 'Optional' is not defined. I simply copied and edited the code snippet from the docs, so I don’t see why I should be getting this error. But what is even more confusing to me is that removing the function annotations don’t fix the problem — instead I get syntax errors. Function annotations are purely optional in Python, and that’s what I understand this method header to be. But there is clearly something more going on that I’m not understanding. I’ve attached the full error message as well as my actions.py file.

actions.py (5.7 KB)

Add the below statement at the beginning of your actions file.

from typing import Optional
2 Likes