Intent must include specific entity from lookup table, otherwise fail gracefully

Hi there, I’m trying to figure this out.

I have a couple of intents that are commands that the bot will act on.

For an example command: show me all [x](entity) where x needs to be a specific term that I’ve added to the entity lookup table.

If the user message includes some other term that is not in the lookup table, I want to show a response with a message like

"I'm sorry, I don't understand that term. Valid terms are x, y, z, etc."

where x, y, z, etc is a list of the valid terms in the entity lookup table (bonus points if the failure response can dynamically respond with valid entity terms from my lookup table).

I’m not sure where or how to configure this.

I can see that the RegexEntityExtractor is finding the specific terms when I enter in an exact match, but for terms not found, it still tries to follow through the next step in my story.

I’ve tried searching for this topic but must not be using the right search terms.

Thanks for your help.

You can read and parse the lookup table in a Custom Action, then check if the value is in that list.

@fishyfishy I also recommend you look into the knowledge base actions feature that could help with your use-case, especially with defining the utter_ask_rephrase in those cases when the user mentions an entity that cannot be found.

1 Like

Thank you @ChrisRahme and Anca for the suggestions, I’ll take a look at those.

Along the same lines, is there also a way to programmatically give the user a list of available commands they can say? I know I could create a response like utter_available_commands that gives a list that I manually curate, but curious to know if this can be automated in some way.

Do you have an example of how to read lookup tables in a custom action? I’m having trouble finding what API to use to get that going.

Just read it as a file like you would in any Python code

Ah, so there’s no built in way using rasa to read what rasa has read into its training data? I’ll do it through reading files thne.

Well there’s the feature that Anca mentioned :slight_smile: