How to handle FormAction using action server?

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.

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? 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?

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

1 Like

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

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

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), 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 function in 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.

1 Like

@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.

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

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?

3 Likes

@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 :smiley:

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

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

Greetings to the whole Rasa team :slight_smile:

1 Like

I have built formAction SDK for Rasa in Nodejs, available in NPM - Nodejs formAction SDK for Rasa

Please suggest what else I can do, by raising an issue at : Issues · rohitnairtech/nodejs-formaction-sdk-rasa · GitHub

Happy to serve! Danke! :wink:

1 Like

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

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!

1 Like

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

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! :pray: :pray:

BTW, I already read RASA docs, but info are insufficient immo, see issues raised:

Thanks
giorgio

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.