It is possible to ask a knowledge base using code?
# 🤝help
a
The same way you can search in a database, is there a way to search into a knowledge base via code instead of using the cards? (https://botpress.com/docs/cloud/toolbox/query-kb/) Thank you
f
Nope. If you are trying to do it outside of Botpress you can use the messaging API which can be found here https://app.botpress.cloud/hub/integrations/intver_01HVM0R2R0QXWNH3BEZPYFK6ZJ
n
If what you are trying to do is pull data only from a specific knowledge base, you can create a folder and insert a workflow and knowledge base inside. When called the agent, it will look only in that kb. Or even more simple in a single choice you should be able to choose which kb to search in
a
not that easy, i need to ask from a code card, it is hard to do what i am triying to do from other cards because there is a lot of logic behind and is not easy to split that code into peaces and use standard botpress logic
f
Have you tried using an expression card with the execute code card and the query knowledge bases card. Have the execute code card return TRUE or FALSE based on some kind of logic that you have. Then use the expression card to check if the variable is TRUE, and if its true then transition to a node with the query knowledge bases card.
a
I wish it were that simple; the logic is inside a recursive function 🤣 . Any way thanks for your help, hopefully they improve that soon
f
Why can't that return a boolean value?
a
it can but in that case I have to simulate several loops using botpress logic. I can be done using "flags" and "counters" and caching data in "object" in workflow variables but will be very slow (I have to create instances of several objects every time) and hard to understand. Just to give you an idea my code have arround 850 lines
f
Ah okay fair enough. Does it return something in a Botpress variable? Like a number?
11 Views