Expression that evaluates if the knowledge base ha...
# 🤝help
b
Hey, What I am looking for is an expression (and thus a variable) that evaluates if the knowledge base has returned an answer or not. I am pretty sure that I've seen it somewhere but I canno't find it back. On that subject, is there a documentation somewhere about all the system variables available (thing like event, workflow...) I don't know if I am blind but I canno't find anything. Thanks a lot
a
Hey @bulky-dusk-45106, try this:
Copy code
js
event.nlu.elected_facts.length == 1 && event.nlu.elected_facts[0].id=="dont_know"
the facts from the knowledge base that are relevant to the user's question are stored in the array
elected_facts
. This expression will check to see if there is only one fact chosen, and then look at that fact to see if it is the built-in "I don't know" fact
There's not much documentation about the system workflow. You can put a request in over at #1111026806254993459 and start a discussion about this!
b
Thank you ! I will try that
So I played around with this expression, but I cannot make it work. No matter if the KB is triggered or not, the elected_facts are only populated by the default "I don't know" value and nothing else. I guess it has to do with where the expression is placed in the flow ? At the moment I trigger the KB with an action card and then put the evaluating expression right after, but it still doesn't work.
a
can you tell me more about how you trigger the KB with an action card?
b
I simply ask a question I know the Kb has the answer to
a
using the api?
b
No in the studio, with an uploaded pdf KB
a
could you share a screenshot of your flow?
b
a
is this box checked on your knowledge agent?
b
Yes
I just tried without it and it didn't change the outcome
a
if that's the case, that expression should go immediately after the Start, like this
b
Ok I will try this
So here the flow will always end up on fact found, wether or not the KB has returned an answer
From what I can gather, elected_facts content never changes no matter if the KB returns something or not. Its value is always 1 and "I don't know"
I just realized that the expression was for the KB not finding an answer lol, so I mixed the result a bit. Sadly this doesn't change the problem that no matter the result of the KB the expression will return true
a
yeah, the expression is for the KB not knowing the answer. It should be the first thing in that node, above any other cards
b
It is:
Here the knowledge base does return something, yet it still ends up on not found
a
What happens if you disable the "enable knowledge answering" on Standard2?
b
Same behavior, wether or not the KB finds something, it ends up on "fact not found"
a
what about if we change
event.nlu.elected_facts.length == 1 && event.nlu.elected_facts[0].id=="dont_know"
to
event.nlu.elected_facts.length === 1 && event.nlu.elected_facts[0].id==="dont_know"
?
basically making everything three = rather than 2
b
Same behavior
To me it seems like event.nlu.elected_facts don't change when the KB is triggered
a
That ought to be the place where any facts (or lack therof) are placed. @acceptable-gold-88171 got any ideas?
b
Just a random theory but with the introduction of the new Knowledge agent, maybe the way the facts are handled has been changed
a
That reminded me that Agent variables are stored in `event.state.agentVariables`maybe there's something there for knowledge agent, let's check
yep, looks like there is something there. Here's what it looks like when I ask a question it doens't know
whereas if it does respond, I get
true
b
Oh nice, so something like event.state.agentVariables.KnowledgeAgent.turn === false should work then
a
That should work, yeah. Give it a try and let me know, eh? 😁
b
Yep it does work ! Thank you for the help ! 🙏
a
awesome, glad we found a solution!
15 Views