https://discord.gg/botpress logo
#🤝help
Trying to determine where or not a Knowledge Base agent found an answer
# 🤝help
s

straight-wolf-37371

06/29/2023, 2:06 PM
I'm using {{event.state.agentVariables.KnowledgeAgent.turn.responded === true}} to try to determine whether or not the answer was found in the knowledge base. Is this the proper var to be looking at? It seems to always be returning false even when I ask a question specificaly out of the knowledge base
b

bulky-dusk-45106

06/29/2023, 2:22 PM
Do you have the "answer on start node" parameter checked in the knowledge agent ?
s

straight-wolf-37371

06/29/2023, 2:24 PM
I do not, I turned it off
b

bulky-dusk-45106

06/29/2023, 2:26 PM
That's why, try to turn it on and run your test again
To explain, in your example the KB canno't be triggered when you test it
c

crooked-hydrogen-21193

06/29/2023, 2:26 PM
just to ask, when you capture the answer from the kb node how do you get it to be written in chat
do you use an ai task and use the exposed var as an input?
and then put the task as "leave this be" and save it as var @answer?
b

bulky-dusk-45106

06/29/2023, 2:28 PM
When using manual answering ?
c

crooked-hydrogen-21193

06/29/2023, 2:28 PM
Yep
b

bulky-dusk-45106

06/29/2023, 2:30 PM
I just started experimenting with it today, but you should be able to use a message card with {{turn.KnowledgeAgent.answer}} in it
c

crooked-hydrogen-21193

06/29/2023, 2:30 PM
did it work for you>
?
b

bulky-dusk-45106

06/29/2023, 2:31 PM
Yeah
The only trouble I had was when I wanted to use an AITask to transform the KB answer
s

straight-wolf-37371

06/29/2023, 2:31 PM
Thanks for the help! When i have it on it answeres the question before it goes to the next node
c

crooked-hydrogen-21193

06/29/2023, 2:31 PM
yeah ive been trying to do that too!
b

bulky-dusk-45106

06/29/2023, 2:32 PM
Somehow if I gave the AI this same variable it would not process it, in that case I used a code card, and placed the turn.KnowledgeAgent.answer inside a workflow variable, then gave the worklow variable to the AITask, and there it worked
c

crooked-hydrogen-21193

06/29/2023, 2:32 PM
basically trying to make stack ai in bot press lol
s

straight-wolf-37371

06/29/2023, 2:33 PM
@daniel do you mean like this?
I stored it in a new var called answer and then used it later
c

crooked-hydrogen-21193

06/29/2023, 2:33 PM
oh dude i had no idea you could have two variables for the input🤯
game changer
s

straight-wolf-37371

06/29/2023, 2:34 PM
Yeah, I wish there were more examples provided! I found that in the docs somewhere
b

bulky-dusk-45106

06/29/2023, 2:34 PM
Yeah so, the way the knowledge agent works is that if it detects a possible answer regarding the user input, it will instantly put it in the chat. In your case I think you want to use a capture card with the knowledge agent activated on it, and then only after test if the kb found something
I'll make a quick example cause its not so clear throught text lol 1 sec
s

straight-wolf-37371

06/29/2023, 2:35 PM
Okay, Im very new so i havent tried the capture cards yet. I will look into those
That would be great if you provide an example! Appreciate it
c

crooked-hydrogen-21193

06/29/2023, 2:36 PM
did you have it like this dude?
b

bulky-dusk-45106

06/29/2023, 2:37 PM
The capture card would have something like "what's your question" inside
and you need to have the knowledge base activated on the node itself like this:
c

crooked-hydrogen-21193

06/29/2023, 2:39 PM
ignore my last message
b

bulky-dusk-45106

06/29/2023, 2:39 PM
That way you can even deactivate the answer on start node, but you will also have to say hello to the bot first because for now the bot needs to "wake up" before answering
s

straight-wolf-37371

06/29/2023, 2:42 PM
Works!!! Thank you
b

bulky-dusk-45106

06/29/2023, 2:44 PM
They also recently added a manual way to use the knowledge base, that's what Daniel and I were talking about above. It is a bit more complicated to use but it can also be more flexible, so you might want to check it out
s

straight-wolf-37371

06/29/2023, 2:46 PM
I saw that. I will check that out. I'm questioning if I even need to do this. I'm wanting to make a bot that answers the questions to the rule of a game. My thought process was to pull all of the relevant rules I could find and then pass to Chat gpt
Knowledge base auto answers seem very good though
b

bulky-dusk-45106

06/29/2023, 2:47 PM
When you say pass them to chatGPT you mean put them inside a knowledge base ?
s

straight-wolf-37371

06/29/2023, 2:49 PM
Using an AI Task to pass what was found in hte knowledge base so chat gpt can read through and formulate an answer
b

bulky-dusk-45106

06/29/2023, 2:52 PM
You can try that, but I think what I would try before it, would be to upload all your rules in a KB. Then add some questioning loop with a capture card waiting for the user's question. The KB answer will depend entirely on the content of it, but I think that game rules should give good answers, you may not even need an AITask for that.
s

straight-wolf-37371

06/29/2023, 2:55 PM
THanks for the advice, I will try that. My worry was hallucinations if the rules are too complex but better to keep it simple if it does answer correctly
b

bulky-dusk-45106

06/29/2023, 2:58 PM
From what I know, the knowledge base only uses NLU. It's a bit like if it were triggered on key words, but better, and its answers will only be what is inside it. As opposed to AITasks that use ChatGPT, here it could hallucinate, but KB don't hallucinate.
s

straight-wolf-37371

06/29/2023, 3:01 PM
Interesting! thats very good to know. I am probably over complicating it. KBs sound like the perfect use case for this
169 Views