How to use FormAction?

Is there a way to use optional filed or to set one of the multiple fields as required

I am looking for something like this

def required_fields():
    # how can i access the slots in this function
    duration = tracker.get_slot("duration")
    return_date = calculate_return_date(departure_date, duration)
    SlotSet("retrun_date", retrun_date)
    return [
        EntityFormField("to", "to"),
        EntityFormField("from", "from"),
        EntityFormField("departure_date", "departure_date"),
        EntityFormField("return_date", "return_date")

what is the right way to achieve this?

We recently released rasa_core and rasa_core_sdk 0.12.1 with the new forms, you can do it there by subclassing required_slots(tracker)

Please see the docs on how to use the new forms

1 Like

hey @Ghostvv can you please tell me how to use form action. I am doing this but my bot gets stuck once i ask pizza ordering query.please tell me whats wrong with my code.

my domain.yml file


  • order_pizza
  • greet
  • size
  • toppings
  • inform
  • affirm
  • goodbye
  • thankyou
  • default


  • size
  • toppings

slots: size: type: text toppings: type: text requested_slot: type: unfeaturized

templates: utter_greet:

  • ‘Hello, how can I help you?’ #- ‘Hi, I am here to help.’ utter_affirm:
  • ‘thanks for the details.your order is being processed’ utter_get_pizza_size:
  • ‘What pizza size?’ utter_get_pizza_toppings:
  • ‘What toppings would you like on your pizza?’ utter_default:
  • ‘sorry!i couldnt understand you.please retry’ utter_thankyou:
  • ‘thanks for connecting’ utter_goodbye:
  • ‘ok…had a great conversation.would like to serve soon’ actions:
  • utter_greet
  • utter_affirm
  • utter_goodbye
  • utter_thankyou
  • utter_default
  • utter_get_pizza_size
  • utter_get_pizza_toppings
  • action_order_pizza
  • action_fill_size
  • action_fill_toppings

default path

  • default
    • utter_default

affirm path

  • affirm
    • utter_affirm

thankyou path

  • thankyou
    • utter_thankyou


  • order_pizza
    • action_order_pizza
    • slot{“requested_slot”: “size”}
  • inform{“size”: “small”}
    • action_order_pizza
    • slot{“requested_slot”: “toppings”}
  • inform{“toppings”: “olives”}
    • action_order_pizza



  • want to book a pizza
  • pizza booking
  • book pizza
  • pizza
  • i want to book an order for pizza


  • hi
  • hii
  • hello
  • hey


  • hey[^\s]*


  • bla bla
  • do you want to marry me
  • i hate you
  • i want something else
  • can you help me?
  • do you love me?
  • fuck you


  • goodbye
  • good bye
  • stop
  • end
  • farewell
  • Bye bye
  • have a good one


  • great
  • right, thank you
  • correct
  • great choice
  • sounds really good
  • yes
  • yep
  • yeah
  • indeed
  • thats ok
  • ok
  • ok fine


  • thanks
  • thank you
  • thank you very much
  • nice
  • thx alot
  • thx
  • appreciated
  • thankx


  • Cheese
  • Cheezy


  • small
  • medium
  • i want small pizza
  • book me a small
  • small pizza
  • large
  • extra large
  • sml
  • lrg
  • big

intent: toppings

  • olives
  • [olives] on top
  • cheese
  • extra cheese
  • cheesy
  • book me a pizza with olives on top
  • book me a pizza with corn

from rasa_core.actions import Action from import SlotSet from rasa_core.actions.action import Action from rasa_core_sdk.forms import FormAction from rasa_core_sdk.forms import EntityFormField class ActionOrderPizza(Action): def required_fields(): return [ EntityFormField(“size”, “size”), EntityFormField(“toppings”, “toppings”) ] def name(self): return ‘action_order_pizza’ def run(self,dispatcher,tracker,domain): size = tracker.get_slot(“size”), toppings = tracker.get_slot(“toppings”) dispatcher.utter_message(“your pizza size of”) dispatcher.utter_message(size) dispatcher.utter_message(“and with toppings”) dispatcher.utter_message(toppings) dispatcher.utter_message(‘Ordering Pizza is completed! It should be with you soon :)’)

it looks like you use old FormAction what version of rasa_core and rasa_core_sdk do you use? It is impossible to read not indented code!

Hey @Ghostvv thanks for listening. I am using rasa core version 0.12.2. here is my file

from rasa_core.actions import Action from import SlotSet

class ActionOrderPizza(FormAction): RANDOMIZE = False

def required_fields():
    return [
        EntityFormField("size", "size"),
        EntityFormField("toppings", "toppings")
def name(self):
    return 'action_order_pizza'
def submit(self,dispatcher,tracker,domain):
    size = tracker.get_slot("size"),
    toppings = tracker.get_slot("toppings")
    dispatcher.utter_message("your pizza size of")
    dispatcher.utter_message("and with toppings")

    dispatcher.utter_message('Ordering Pizza is completed! It should be with you soon :)')

what version of rasa_core_sdk do you use? EntityFormField is not supported anymore

i am using rasa_core_sdk verion 0.12.1. if not EntityFormField then what is to be used?

Please check the docs: Slot Filling

hey @Ghostvv how can I use formAction in Node.js instede of python

1 Like

You need to implement all the methods in FormAction class in Node.js, make sure that you return the same jsons

Even if I skip the rasa-sdk for my project? Do you have any resource link for formAction In node @Ghostvv

Basically, you’d need to implement rasa_sdk in Node.js. I’m sorry, I don’t have any links for this

I’m implementing formAction in nodeJS. but fails while deactivating a form. any idea about form in node js or how to deactivate form using nodejs. I guess in formAction using rasa-SDK we need to give null in story. I tried same but it doesn’t work. and when a form is excuted it gives the same responce 10times with warning “circuit break tripped. stopped predicting more actions for sender default”

I have released a formAction SDK for Rasa in Nodejs. Adding more customisations : formAction SDK for Rasa in Nodejs

You can add issues and suggestions here: Issues · rohitnairtech/nodejs-formaction-sdk-rasa · GitHub

Please let me know what more to add! :slight_smile:



1 Like

@capgos17 we had already done that. Thanks @rohitnairtech for publishing in npm community.


Hi @rohitnairtech do you know about implementation of RASA voice bot? I am facing issue there. As everything is executing well but might servers not getting connected. I am follwing this link: How to build a voice assistant with open source Rasa and Mozilla tools

Did you resolve this? What is the error you are getting?