FormAction not registered to function server

I am new to Rasa and I am currently learning how to use the FormAction, however, I have the following problem:

I have one simple storyline here (I removed most of the code from my files and only left those that are necessary to reproduce the error, for simplicity sake.): (136 Bytes)

When the bot preditcs a ‘greet’ user intent, it greets back, calls an ‘action_hello_world’ custom function, and then calls the FormAction ‘purchase_form’. The implementation of the FormAction and the custom function I have attached below: (2.8 KB)

After training the model, i ran the action server and the rasa shell, I get the following:

As indicated by the first and second line after my input, the bot correctly performs ‘utter_greet’ and calls the customfunction ‘action_hello_world’, however it could not call the FormAction ‘purchase_form’. And rightly, it wasn’t even registered when I ran the server action:

I was wondering if anyone could point out what I am missing?

Some additional files that might be necessary to look at:

config.yml (479 Bytes) domain.yml (798 Bytes) endpoints.yml (57 Bytes)

I am using Rasa 1.7.0 and Python 3.7.6

If this seems like a common beginner’s problem and that I’ve missed something in the tutorial, I do apologize and I would appreciate it if I could be redirected to the proper tutorial page.

It looks like you’re missing your mappings. In your action, in the PurchaseForm class, you need to add a slot_mappings method

Something like this:

    def slot_mappings(self) -> Dict[Text, Union[Dict, List[Dict]]]:
        """Dictionary to map required slots"""

        return { "colour": [
                entity="colour", intent=["aaa", "bbb"]
            "material": [
                entity="material", intent=["ccc", "ddd"]

aaa, bbb, ccc, ddd would be examples in your NLU of phrases how the user would say what colour or what material. For example:

## intent: get_colour
- the colour is [blue](colour)

(add more examples of phrases).

Hope this helped

Link to the docs:

I had this function before and unfortunately it didnt solve the problem. Besides, from the docs it states:

“If you do not define slot mappings, slots will be only filled by entities with the same name as the slot that are picked up from the user input.”

For each slot name I already have a corresponding domain object with the same name, that’s why I purposely left out the slot_mappings functions.

I found the solution, which might be because of a bug or that I installed something incorrectly. My initial problem was that ‘rasa run actions’ could only register functions that inherits from the class ‘Action’ but could not do the same to functions that inherits from ‘FormAction’. I found out that the function server does not register functions that inherits from ‘Action’ that is imported from rasa_core_sdk, and that it imports only the functions that inherits from ‘Action’ imported from rasa_sdk. In, FormAction is a subclass of Action that is imported from rasa_core_sdk. I changed the so that it imports from rasa_sdk instead and it works.