How to use slots, lookup table, action and DB to answer question

So I use this intent: info about [cybersecurity](major_name) combine with lookup table of possible major names. Now I want the chatbot to respond with information about the major asked, the infos are stored in a database. I also want to ask about the event slot_was_set and is it relate to it.

Hi @vunhatchuong123

Welcome to the community.

You can achieve it by writing a custom action. In the custom action, call the database with the major_name and return the information back to the user via dispatcher.

Is it better to use Knowledge base for this?

Hi @vunhatchuong123 by Knowledge Base do you mean using KnowledgeBaseAction ? I guess for the purpose you described the custom action which queries a Database (which is nothing else but a knowledge base) should be apt. I think it is much better in terms of flexibility and control.

Yeah that’s what I meant. I’m trying to find a way to do with with KnowledgeBaseAction .

Maybe use ActionQueryKnowledgeBase, InMemoryKnowledgeBase? I don’t know

Hi @vunhatchuong123 … Under the hood ActionQueryKnowledgeBase uses the same technique as far as I know. I would not recommend InMemoryKnowkedgeBase as that is only good for testing or dev phase.

However I find it more flexible to have -

  1. My knowledge base in an external system. E.g. have a mapping of the key (major_name) against its response.
  2. Have a custom action that get triggers when the intent is detected e.g. info_about.
  3. Query my knowledge base based on the key and get back the response in the custom action.
  4. Send the respons back using the dispatcher

So I currently have a custom action that open my temporary DB.json located in /data/ which works fine but I would like to use something from Rasa library (Ex:ActionQueryKnowledgeBase). I don’t know if it’s better or not tho