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.):

stories.md (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:

actions.py (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": [
            self.from_entity(
                entity="colour", intent=["aaa", "bbb"]
            ),
            self.from_entity(entity="colour")],
            "material": [
            self.from_entity(
                entity="material", intent=["ccc", "ddd"]
            ),
            self.from_entity(entity="material")]
        }

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: