Call a form inside custom action

Hello, is it possible within the custom action to call a form in the domain?

form2

@RodrigoLima Hello, as far as I know, it is not possible to call the forms in the dispatcher, for more info on what we can include, please see this ref link : Dispatcher

@RodrigoLima Even, in the code; I can see some error please check the syntax :slight_smile:

def run(
        self,
        dispatcher: CollectingDispatcher,
        tracker: Tracker,
        domain: Dict[Text, Any],
    ) -> List[EventType]:

        dispatcher.utter_message(text = "Hi, User!")

Error: you missing dispatcher: CollectingDispatcher, or I am missing something in the code lines?

Good Luck!@

In your Custom Action, return the FollowupAction event:

return [FollowupAction("form_comprar_item_pagina")]
1 Like

tks, i will make the change.

@nik202 The colon “:” in python is an annotation. It is used for type checking. In other words the variable dispatcher is of type CollectingDispatcher.

In this case, the method run works fine without the type check.

So the method:

def run(
        self,
        sender,
        tracker,
        domain,
    ) -> List[EventType]:

        dispatcher.utter_message(text = "Hello, user!")

works just as well as the method:

def run(
        self,
        sender: CollectingDispatcher,
        tracker: Tracker,
        domain:Dict[Text, Any],
    ) -> List[EventType]:

        dispatcher.utter_message(text = "Hello, user!")

The main difference is that in the last example python knows that the varible dispatcher is of type “CollectingDispatcher”, the varible tracker is of type “Tracker” and the varible domain is of type “Dict”.

Both methods will work, but the latter is the better practice, not an error.

1 Like

Em bom português: ficou perfeito. Tnks

1 Like

@ChrisRahme Yes, I missed that :frowning: Great you sorted the issue.

1 Like

Feliz por ajudar :slight_smile: