https://discord.gg/botpress logo
Multiple dynamic Search Knowledge Base
# 🤝help
b
For the Search Knowledge Base card, is there a way I can search in multiple knowledge bases dynamically (for example using an array of knowledge base IDs)? Or does one card correspond to only one knowledge base? Our problem is that our knowledge documents correspond to product serial numbers, so for example serial #1 includes documents A,B, & C but serial #2 only includes B & C; so when the customer gives the bot their serial number, if it's #2 we do NOT want the bot to search knowledge base for document A. How can we solve this problem?
o
Inside the search knowledge base card, if you click the { x } button, you can pass variables in there. The values of the variable must be the kb-id of the kb you will be searching. What I recommend doing is having an execute code card OR an action (if needed to be determined by the autonomous node) that determines (however best fits your use case) which kb the bot needs to search. Example code: (my example is for searching the shampoo kb if a user's message contains the word shampoo)
Copy code
js
if (event.preview.toLowerCase().includes("shampoo")) {
  // we can assume the user is asking for shampoo
  // search the shampoo kb
  workflow.kbId = "place-the-kb-id"
  return ...
}
and then after calling such an action or execute code card, you would query the kb or search the kb with passing {{workflow.kbId}} inside the "Included Knowledge Bases" tab.
b
My problem is that knowledge would be spread across multiple knowledge bases; is it possible to do something like
{{['kb-id1', 'kb-id2']}}
in the Included Knowledge Bases section in order to have the bot look in those two knowledge bases?
o
instead of having workflow.kbId be a string, you can have it be an array of strings and call it workflow.kbIds