Rasa Optional Slots Artinya Dalam Bahasa Indonesia

Rasa Optional Slots Artinya Dalam Bahasa Indonesia

I wonder what’s the best way of creating slots, that are not obligatory.

What I mean by that? Let me define a form as presented below:

Now, in order to perform an actual search in my database I need either ‘5_service’ or ‘6_specialist_name’ or ‘7_specialization’. I don’t need all 3, although if user provides them in one sentence, then that’s not a problem. I will run a DB search with 3 parameters, not 1 or 2. So how to make form take this into account? It should accept just one response with either 1,2 or 3 parameters (slots). If just one is provided, then it shouldn’t investigate other two? And if two or three are given (in one response), then that’s okey as well.

I saw this issue add possibility to define optional slots for forms · Issue #6939 · RasaHQ/rasa · GitHub, but as I understand - it’s currently on hold, so… What’s the best alternative?

There are two solutions, that I’ve thought of:

What I don’t like about these solutions is neither of them seems to be an elegant one.

You could write validation methods for each of the three slots which fill the other two slots if there’s enough information already. That way it will consider them all filled; they won’t be “optional”, but the user won’t be prompted for them.

Yes. This solution works pretty well Thanks!

The default implementation of the Form Action mandates that all the fields listed in required_fields have to be filled before the submit method is triggered. But I have a slightly different scenario where submit can be triggered as long as some of the slots are filled. For ex: I have the following slots - city, state, country, category, product type. I just need one of city / state / country and one of category / product type to be filled before calling the submit method. I implemented a complicated way of doing it by making required_fields a list of lists as follows: [[city, state, category], [category, skills]] & checking if one slot in each of the list is filled. But is there a better way of implementing this? Any help would be appreciated

Basically I would make an option slot by doing this:

NOT adding it to required_slots

Adding it to slot_mappings

So if the slot is found on the text it would map anyway even when not required. But this would mean it would not ask for the slot. That means if you want to actively ask for it. The best way would be to put it on required_slots and give an “skip” option. It could be a quick-reply for example.

In your case specific case I would do one of the following:

Put everything on required and slotmapping. Add “request_next_slot” and “validate” to the method. On request_next_slot, I would check if at least one of the city/state/country was mapped if yes I would pass in the return: return [SlotSet(REQUESTED_SLOT, slot)] where “slot” would be equal to category or product. Otherwise if category or product was also filled you would return None

Hi @Sekhar-jami can u explain more on how to implement optional slots using your approach list of lists…In my case i just want to check for 2 slots (account number/trans ID)…so i feel your approach will do the job for me.

there are several ways to achieve this @custodio suggests a working example. For the sake of simplicity and if there is no need to validate the slots through the FormAction validators, you could also use a CustomAction instead of a FormAction by using:

So you just would have to decide when to trigger whatever is triggered in your previous submit method.

Anda mungkin ingin melihat