# How to use FormAction?

**URL:** <https://forum.rasa.com/t/how-to-use-formaction/2770>\
**Category:** Rasa Open Source\
**Created:** [November 19, 2018, 5:02am UTC](https://forum.rasa.com/t/how-to-use-formaction/2770 "2018-11-19T05:02:10Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![DEVELByte](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/develbyte/32/691_2.png) [@DEVELByte](https://forum.rasa.com/u/DEVELByte)\
**Post date:** [November 19, 2018, 5:02am UTC](https://forum.rasa.com/t/how-to-use-formaction/2770/1 "2018-11-19T05:02:10Z")

</div>

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

```auto
@staticmethod
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?

---

<div class="post-metadata">

**Author:** ![Ghostvv](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/ghostvv/32/211_2.png) [@Ghostvv](https://forum.rasa.com/u/Ghostvv)\
**Post date:** [November 20, 2018, 9:51am UTC](https://forum.rasa.com/t/how-to-use-formaction/2770/2 "2018-11-20T09:51:36Z")

</div>

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)`

> <https://github.com/RasaHQ/rasa_core_sdk/blob/47106d959767148d15b328a3a38a95cd697e0616/rasa_core_sdk/forms.py#L34>

Please see the docs on how to use the new forms

---

<div class="post-metadata">

**Author:** ![pragya-96](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/pragya-96/32/1591_2.png) [@pragya-96](https://forum.rasa.com/u/pragya-96)\
**Post date:** [January 11, 2019, 12:03pm UTC](https://forum.rasa.com/t/how-to-use-formaction/2770/3 "2019-01-11T12:03:22Z")

</div>

hey @Ghostvvcan 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

intents:

- order\_pizza
- greet
- size
- toppings
- inform
- affirm
- goodbye
- thankyou
- default

entities:

- 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

stories.md

## default path

- default
  - utter\_default

## affirm path

- affirm
  - utter\_affirm

## thankyou path

- thankyou
  - utter\_thankyou

## story\_path\_1

- 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

my nlu.md

## intent:order\_pizza

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

## intent:greet

- hi
- hii
- hello
- hey

## regex:greet

- hey[^\s]\*

## intent:default

- 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

## intent:goodbye

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

## intent:affirm

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

## intent:thankyou

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

## synonym:cheesy

- Cheese
- Cheezy

## intent:size

- small
- medium
- i want [small](https://github.com/RasaHQ/rasa_core_sdk/issues/size) pizza
- book me a [small](https://github.com/RasaHQ/rasa_core_sdk/issues/pizza)
- [small](https://github.com/RasaHQ/rasa_core_sdk/issues/size) pizza
- large
- extra large
- sml
- lrg
- big

## intent: toppings

- olives
- [olives] on top
- cheese
- extra cheese
- cheesy
- book me a pizza with [olives](https://github.com/RasaHQ/rasa_core_sdk/issues/toppings) on top
- book me a pizza with [corn](https://github.com/RasaHQ/rasa_core_sdk/issues/toppings)

actions.py

from rasa\_core.actions import Action from rasa\_core\_sdk.events 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 :)’)

---

<div class="post-metadata">

**Author:** ![Ghostvv](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/ghostvv/32/211_2.png) [@Ghostvv](https://forum.rasa.com/u/Ghostvv)\
**Post date:** [January 11, 2019, 12:20pm UTC](https://forum.rasa.com/t/how-to-use-formaction/2770/4 "2019-01-11T12:20:48Z")

</div>

> [@pragya-96](#):
>
> EntityFormField

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!

---

<div class="post-metadata">

**Author:** ![pragya-96](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/pragya-96/32/1591_2.png) [@pragya-96](https://forum.rasa.com/u/pragya-96)\
**Post date:** [January 14, 2019, 6:35am UTC](https://forum.rasa.com/t/how-to-use-formaction/2770/6 "2019-01-14T06:35:19Z")

</div>

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

from rasa\_core.actions import Action from rasa\_core\_sdk.events import SlotSet

class ActionOrderPizza(FormAction): RANDOMIZE = False

```
@staticmethod
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(size)
    dispatcher.utter_message("and with toppings")
    dispatcher.utter_message(toppings)

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

---

<div class="post-metadata">

**Author:** ![Ghostvv](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/ghostvv/32/211_2.png) [@Ghostvv](https://forum.rasa.com/u/Ghostvv)\
**Post date:** [January 14, 2019, 11:52am UTC](https://forum.rasa.com/t/how-to-use-formaction/2770/7 "2019-01-14T11:52:54Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![pragya-96](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/pragya-96/32/1591_2.png) [@pragya-96](https://forum.rasa.com/u/pragya-96)\
**Post date:** [January 14, 2019, 12:36pm UTC](https://forum.rasa.com/t/how-to-use-formaction/2770/8 "2019-01-14T12:36:28Z")

</div>

i am using rasa\_core\_sdk verion 0.12.1. if not EntityFormField then what is to be used?

---

<div class="post-metadata">

**Author:** ![Ghostvv](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/ghostvv/32/211_2.png) [@Ghostvv](https://forum.rasa.com/u/Ghostvv)\
**Post date:** [January 14, 2019, 12:37pm UTC](https://forum.rasa.com/t/how-to-use-formaction/2770/9 "2019-01-14T12:37:33Z")

</div>

Please check the docs: [Slot Filling](https://rasa.com/docs/core/slotfilling/)

---

<div class="post-metadata">

**Author:** ![capgos17](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/capgos17/32/3895_2.png) [@capgos17](https://forum.rasa.com/u/capgos17)\
**Post date:** [August 8, 2019, 6:34am UTC](https://forum.rasa.com/t/how-to-use-formaction/2770/10 "2019-08-08T06:34:54Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Ghostvv](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/ghostvv/32/211_2.png) [@Ghostvv](https://forum.rasa.com/u/Ghostvv)\
**Post date:** [August 8, 2019, 7:53am UTC](https://forum.rasa.com/t/how-to-use-formaction/2770/11 "2019-08-08T07:53:36Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![capgos17](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/capgos17/32/3895_2.png) [@capgos17](https://forum.rasa.com/u/capgos17)\
**Post date:** [August 9, 2019, 5:26am UTC](https://forum.rasa.com/t/how-to-use-formaction/2770/12 "2019-08-09T05:26:19Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Ghostvv](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/ghostvv/32/211_2.png) [@Ghostvv](https://forum.rasa.com/u/Ghostvv)\
**Post date:** [August 9, 2019, 2:57pm UTC](https://forum.rasa.com/t/how-to-use-formaction/2770/13 "2019-08-09T14:57:30Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![capgos17](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/capgos17/32/3895_2.png) [@capgos17](https://forum.rasa.com/u/capgos17)\
**Post date:** [August 22, 2019, 9:06am UTC](https://forum.rasa.com/t/how-to-use-formaction/2770/15 "2019-08-22T09:06:07Z")

</div>

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”

 ![Screenshot from 2019-08-22 14-04-08.png](https://europe1.discourse-cdn.com/flex013/uploads/rasa/original/2X/d/d804be9ff1ab63f564f8aa200d35143074f338e5.png)

---

<div class="post-metadata">

**Author:** ![rohitnairtech](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/rohitnairtech/32/2100_2.png) [@rohitnairtech](https://forum.rasa.com/u/rohitnairtech)\
**Post date:** [March 2, 2020, 9:43am UTC](https://forum.rasa.com/t/how-to-use-formaction/2770/16 "2020-03-02T09:43:33Z")

</div>

I have released a formAction SDK for Rasa in Nodejs. Adding more customisations : [formAction SDK for Rasa in Nodejs](https://www.npmjs.com/package/nodejs-formaction-sdk-rasa)

You can add issues and suggestions here: [Issues · rohitnairtech/nodejs-formaction-sdk-rasa · GitHub](https://github.com/rohitnairtech/nodejs-formaction-sdk-rasa/issues)

Please let me know what more to add! 🙂

---

<div class="post-metadata">

**Author:** ![capgos17](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/capgos17/32/3895_2.png) [@capgos17](https://forum.rasa.com/u/capgos17)\
**Post date:** [March 2, 2020, 1:27pm UTC](https://forum.rasa.com/t/how-to-use-formaction/2770/18 "2020-03-02T13:27:58Z")

</div>

@shashank34

---

<div class="post-metadata">

**Author:** ![shashank34](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/shashank34/32/5110_2.png) [@shashank34](https://forum.rasa.com/u/shashank34)\
**Post date:** [March 13, 2020, 10:08am UTC](https://forum.rasa.com/t/how-to-use-formaction/2770/19 "2020-03-13T10:08:35Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![bjaldoshi](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/bjaldoshi/32/7734_2.png) [@bjaldoshi](https://forum.rasa.com/u/bjaldoshi)\
**Post date:** [March 17, 2020, 5:14am UTC](https://forum.rasa.com/t/how-to-use-formaction/2770/20 "2020-03-17T05:14:03Z")

</div>

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](https://blog.rasa.com/how-to-build-a-voice-assistant-with-open-source-rasa-and-mozilla-tools/)

---

<div class="post-metadata">

**Author:** ![noushad](https://avatars.discourse-cdn.com/v4/letter/n/7c8e57/32.png) [@noushad](https://forum.rasa.com/u/noushad)\
**Post date:** [June 8, 2020, 8:43pm UTC](https://forum.rasa.com/t/how-to-use-formaction/2770/21 "2020-06-08T20:43:23Z")

</div>

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