Using a subset of list-type slot values in an utter_action

(Leo@Vocinity) #1

My bot sends a query to the api that returns either a multiple or single response:

For example: how many definitions are there for a word? The answer is stored in a “definitions” slot that is a list. Sometimes there will be multiple answers, sometimes single ones. Depending on the answer I want to have an utter_action that will give a single response or a list of responses. So far I found two ways to do it:

a) have one utter action: “utter_definition” that looks like this:"The definition of {word} {definition_string} and i have a custom action before every utter_definition, that will either take the single answer or a the definitions slot list and convert it into a string.

This keeps the number of utter_actions down, but makes for a lot of custom actions, such as get_one_definition, get_all_definitions, get_some_definitions etc.

b) have many utter action for each option, each one using a different slot, so instead of just my “definitions” list slot, i’d also have a “top_definition”, “second_definition” etc.

This is ok when you have one or two utter_actions and slots, but it quickly gets unmanageable when you have 10 utter_actions and 10 slots and you have make a single and plural version of each one.

The fundamental problem here is that when working with a list type slot, there’s no way, as far as I know, to tell Rasa, via the stories and domain file to use a subset of that list. Is there a way to do that?