# How to handle FormAction using action server?

**URL:** <https://forum.rasa.com/t/how-to-handle-formaction-using-action-server/15303>\
**Category:** Rasa Open Source\
**Created:** [September 5, 2019, 10:25pm UTC](https://forum.rasa.com/t/how-to-handle-formaction-using-action-server/15303 "2019-09-05T22:25:59Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![tom1](https://avatars.discourse-cdn.com/v4/letter/t/b487fb/32.png) [@tom1](https://forum.rasa.com/u/tom1)\
**Post date:** [September 5, 2019, 10:25pm UTC](https://forum.rasa.com/t/how-to-handle-formaction-using-action-server/15303/1 "2019-09-05T22:25:59Z")

</div>

Hello all, I try to handle FormAction in my java action server, and I’m stuck. How to return the required slot list? I have tried with the following response:

```
{
  "events": [
    {
        "event": "slot",
        "timestamp": 1567721549582,
        "name": "date"
    },
    {
        "event": "slot",
        "timestamp": 1567721549582,
        "name": "from"
    },
    {
        "event": "slot",
        "timestamp": 1567721549582,
        "name": "to"
    }
  ]

```

}

but without luck. The rasa core log:

chatbot\_rasa.1.p8lb1ao11xkv@default | 2019-09-05 22:02:09 DEBUG rasa.core.actions.action - Calling action endpoint to run action ‘booking\_form’. chatbot\_rasa.1.p8lb1ao11xkv@default | 2019-09-05 22:02:11 DEBUG rasa.core.processor - Action ‘booking\_form’ ended with events ‘[‘SlotSet(key: date, value: None)’, ‘SlotSet(key: from, value: None)’, ‘SlotSet(key: to, value: None)’]’ chatbot\_rasa.1.p8lb1ao11xkv@default | 2019-09-05 22:02:11 WARNING rasa.core.processor - Action ‘booking\_form’ set a slot type ‘date’ that it never set during the training. This can throw of the prediction. Make sure to include training examples in your stories for the different types of slots this action can return. Remember: you need to set the slots manually in the stories by adding ‘- slot{“date”: null}’ after the action. chatbot\_rasa.1.p8lb1ao11xkv@default | 2019-09-05 22:02:11 WARNING rasa.core.processor - Action ‘booking\_form’ set a slot type ‘from’ that it never set during the training. This can throw of the prediction. Make sure to include training examples in your stories for the different types of slots this action can return. Remember: you need to set the slots manually in the stories by adding ‘- slot{“from”: null}’ after the action. chatbot\_rasa.1.p8lb1ao11xkv@default | 2019-09-05 22:02:11 WARNING rasa.core.processor - Action ‘booking\_form’ set a slot type ‘to’ that it never set during the training. This can throw of the prediction. Make sure to include training examples in your stories for the different types of slots this action can return. Remember: you need to set the slots manually in the stories by adding ‘- slot{“to”: null}’ after the action. chatbot\_rasa.1.p8lb1ao11xkv@default | 2019-09-05 22:02:11 DEBUG rasa.core.processor - Current slot values: chatbot\_rasa.1.p8lb1ao11xkv@default | date: None chatbot\_rasa.1.p8lb1ao11xkv@default | from: None chatbot\_rasa.1.p8lb1ao11xkv@default | requested\_slot: None chatbot\_rasa.1.p8lb1ao11xkv@default | to: None

How can I handle FormAction using action server?

Thank you in advance for any help.

---

<div class="post-metadata">

**Author:** ![akelad](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/akelad/32/69_2.png) [@akelad](https://forum.rasa.com/u/akelad)\
**Post date:** [September 6, 2019, 9:46am UTC](https://forum.rasa.com/t/how-to-handle-formaction-using-action-server/15303/2 "2019-09-06T09:46:28Z")

</div>

Hey @tom1, welcome to the forum! Are you trying to replicate the behaviour of a form in a java server? That’s really interesting to see - we’d love it if you could share your implementation once you’re finished. Have you taken a look at the implementation of the FormAction in the python format [here](https://github.com/RasaHQ/rasa-sdk/blob/master/rasa_sdk/forms.py)? It’s just a list, no need to be in the form of a dictionary. You need to replicate all the behaviour in the sdk as well btw. It seems like from the logs the form isn’t active - are you setting the `active_form` in the tracker correctly?

---

<div class="post-metadata">

**Author:** ![tom1](https://avatars.discourse-cdn.com/v4/letter/t/b487fb/32.png) [@tom1](https://forum.rasa.com/u/tom1)\
**Post date:** [September 6, 2019, 9:56pm UTC](https://forum.rasa.com/t/how-to-handle-formaction-using-action-server/15303/3 "2019-09-06T21:56:49Z")

</div>

Hi @akelad thank you for your answer! Currently, I’m building the action server in java and has worked as expected until the FormAction has appeared 🙂. Thank you for the example of code in Python, I will try to implement based on it. I will share my implementation of acton server in java once I’m finished.

---

<div class="post-metadata">

**Author:** ![akelad](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/akelad/32/69_2.png) [@akelad](https://forum.rasa.com/u/akelad)\
**Post date:** [September 13, 2019, 11:54am UTC](https://forum.rasa.com/t/how-to-handle-formaction-using-action-server/15303/4 "2019-09-13T11:54:50Z")

</div>

Awesome thanks! Let me know if you have any more questions

---

<div class="post-metadata">

**Author:** ![tom1](https://avatars.discourse-cdn.com/v4/letter/t/b487fb/32.png) [@tom1](https://forum.rasa.com/u/tom1)\
**Post date:** [October 18, 2019, 10:25am UTC](https://forum.rasa.com/t/how-to-handle-formaction-using-action-server/15303/5 "2019-10-18T10:25:09Z")

</div>

Hi @akelad . Sorry for the delay - I was fully loaded recently and my time was really short. But I’m back 🙂 .

I have already implemented SDK for Java. Python’s version has been ported to Java. I have been doing some tests and I can say that the beta version is ready. Now I’m in the middle of the running Rasa Java SDK supporting the “Restaurant search assistant using Rasa Forms” ([The original tutorial](https://blog.rasa.com/building-contextual-assistants-with-rasa-formaction/)), and the results are well so far. The bot works the same as with Python’s SDK.

The next steps:

1. Prepare a production-ready version of Java SDK
2. Prepare documentation

I have one question about the “validate\_{slot}” functions. Currently, those should return a dict of {‘slot\_name’: value} instead of value. And I’m wondering why you have changed this? The Java SDK supports this same behavior, but from my perspective, each validation function should be related to one, appropriate slot. The relation should be “one-to-one”. Now, validation\_{slot} can handle multiple slots (please have a look at the [test\_set\_slot\_within\_helper](https://github.com/RasaHQ/rasa-sdk/blob/dd8bac24172fa9d838eb9c68a6bbc129cc95c8f0/tests/test_forms.py#L673) function in [test\_forms.py](https://github.com/RasaHQ/rasa-sdk/blob/dd8bac24172fa9d838eb9c68a6bbc129cc95c8f0/tests/test_forms.py))

May I ask you for more details, why the “validation\_{slot}” function does not return validation results for only one slot? Unless I overlooked or misunderstood something.

Thank you.

---

<div class="post-metadata">

**Author:** ![akelad](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/akelad/32/69_2.png) [@akelad](https://forum.rasa.com/u/akelad)\
**Post date:** [October 22, 2019, 9:32am UTC](https://forum.rasa.com/t/how-to-handle-formaction-using-action-server/15303/6 "2019-10-22T09:32:16Z")

</div>

@tom1 that’s amazing news! Do you have a repository with the code to share yet?

As for your question: that implementation was intentional. It’s possible that based on the validation of one of the slots, a different one might also need to be set.

---

<div class="post-metadata">

**Author:** ![tom1](https://avatars.discourse-cdn.com/v4/letter/t/b487fb/32.png) [@tom1](https://forum.rasa.com/u/tom1)\
**Post date:** [November 13, 2019, 10:44pm UTC](https://forum.rasa.com/t/how-to-handle-formaction-using-action-server/15303/7 "2019-11-13T22:44:01Z")

</div>

Hi @akelad. Thank you for the explanation, it’s clear now. Regarding the code of the SDK, there are two repositories:

- [GitHub - rbajek/rasa-java-sdk: Java SDK for the development of custom actions for Rasa](https://github.com/rbajek/rasa-java-sdk) - for the SDK which can be used of both an existing system and build from scratch
- [GitHub - rbajek/rasa-java-action-server: Action server for the Rasa custom actions](https://github.com/rbajek/rasa-java-action-server) - for the action server, which can be used as a starting point for the new projects.

The current version of SDK supports the last stable version of Rasa - 1.4.x.

So, from now, we have SDK for Python (your implementation) and Java (my). It would be great if we will have example requests and responses, which can be used to validate our SDKs. It would be helpful when the new version of Rasa will arise, and based on the “contract” (those requests - responses), we can check the newest versions of the SDKs whether working well. It would be some kind of certification path.

What do you think?

---

<div class="post-metadata">

**Author:** ![akelad](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/akelad/32/69_2.png) [@akelad](https://forum.rasa.com/u/akelad)\
**Post date:** [November 27, 2019, 12:45pm UTC](https://forum.rasa.com/t/how-to-handle-formaction-using-action-server/15303/8 "2019-11-27T12:45:59Z")

</div>

@tom1 sorry for the late reply (was travelling), that’s awesome that you built this and open sourced it as well! We’re gonna discuss your suggestions and let you know 😃

---

<div class="post-metadata">

**Author:** ![tom1](https://avatars.discourse-cdn.com/v4/letter/t/b487fb/32.png) [@tom1](https://forum.rasa.com/u/tom1)\
**Post date:** [November 27, 2019, 1:40pm UTC](https://forum.rasa.com/t/how-to-handle-formaction-using-action-server/15303/9 "2019-11-27T13:40:26Z")

</div>

@akelad thanks for your comment. Rasa is awesome, so I’m very happy that I could put my small brick to the Rasa stack 🙂. I hope the Java SDK will open Rasa for the Java world 🙂!

If you will have some information about my suggestion or any others, please let me know.

Greetings to the whole Rasa team 🙂

---

<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 3, 2020, 4:17am UTC](https://forum.rasa.com/t/how-to-handle-formaction-using-action-server/15303/10 "2020-03-03T04:17:59Z")

</div>

I have built formAction SDK for Rasa in Nodejs, available in NPM - [Nodejs formAction SDK for Rasa](https://www.npmjs.com/package/nodejs-formaction-sdk-rasa)

Please suggest what else I can do, by raising an issue at : [Issues · rohitnairtech/nodejs-formaction-sdk-rasa · GitHub](https://github.com/rohitnairtech/nodejs-formaction-sdk-rasa/issues)

Happy to serve! Danke! 😉

---

<div class="post-metadata">

**Author:** ![akelad](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/akelad/32/69_2.png) [@akelad](https://forum.rasa.com/u/akelad)\
**Post date:** [March 3, 2020, 10:15am UTC](https://forum.rasa.com/t/how-to-handle-formaction-using-action-server/15303/11 "2020-03-03T10:15:45Z")

</div>

That’s really great! Just one question - this is only to build custom actions with right? Not to actually run the SDK ?

---

<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 10, 2020, 2:16am UTC](https://forum.rasa.com/t/how-to-handle-formaction-using-action-server/15303/12 "2020-03-10T02:16:50Z")

</div>

Ja Akela, this one just mimics formAction from the python actions SDK provided. Now I’m working on adding additional features like external NLG… Will update soon!

---

<div class="post-metadata">

**Author:** ![solyarisoftware](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/solyarisoftware/32/8464_2.png) [@solyarisoftware](https://forum.rasa.com/u/solyarisoftware)\
**Post date:** [May 18, 2020, 1:15pm UTC](https://forum.rasa.com/t/how-to-handle-formaction-using-action-server/15303/13 "2020-05-18T13:15:06Z")

</div>

Hi @tom1, I enjoyed and starred your java projects on github! 👏👏

As nodejs developer, I’d like to implement (and I’ll glad to share on github) something similar to what you did in Java, splitting general/form actions cases.

To avoid to re-engineer your (well done) code (and the RASA core python code too), and avoiding to reinvent the wheel coding with trial & errors approach, my question to @akelad and any other RASA people:

There is any **external Action server webhook HTTP API request/reply JSON payloads documentation/specification/details? If not I please ask to supply a clear API interface docs! 🙏 🙏**

> BTW, I already read RASA docs, but info are insufficient immo, see issues raised:
> 
> - [Documentation details about how to run an external Action Server · Issue #5763 · RasaHQ/rasa · GitHub](https://github.com/RasaHQ/rasa/issues/5763)
> - [Documentation "lacks": confused with RASA NLU/Core HTTP (REST) API doc · Issue #5749 · RasaHQ/rasa · GitHub](https://github.com/RasaHQ/rasa/issues/5749#issuecomment-623969412)

Thanks  
giorgio

---

<div class="post-metadata">

**Author:** ![maniteja6799](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/maniteja6799/32/12787_2.png) [@maniteja6799](https://forum.rasa.com/u/maniteja6799)\
**Post date:** [October 21, 2020, 5:03am UTC](https://forum.rasa.com/t/how-to-handle-formaction-using-action-server/15303/14 "2020-10-21T05:03:48Z")

</div>

Hi @tom1 , i was just checking out the java sdk/actionServer. Great work. Wanted to ask couple of questions. Would this be compatible with Rasa 2.0? From what i’ve learnt so far about rasa, I don’t think there are many changes needed. What do you think?

Thanks, Teja.
