https://discord.gg/botpress logo
#🌎general
Title
# 🌎general
r

rich-oxygen-43707

07/01/2023, 5:37 PM
This is pretty simple, I am sure, but I am missing something. - I have a KB. - I have a "Raw Input" that asks user what their question is. - Then I have an "Intent" that branches to a different node if they ask a specific question that I want to handle separately. - Then I have a "No answer from knowledge" card that branches to a different node. But what do I need to add to this flow to answer the question if it is answerable from the KB? Edit: I see that I can add a Send Text card and display {{turn.KnowledgeAgent.answer}} but there is nothing in that variable. Do I need to manually send the question to the Knowledge Agent somehow? (Interestingly, I know if all I had was a "Start" and "End" there is magic built in that would cause a question to be answered from the KB. I just need to know how to make that happen further into the flow when the question is a Capture result, as opposed to the first input the user types to wake up the bot and start a conversation.)
e

early-train-33247

07/02/2023, 12:38 AM
Hey @rich-oxygen-43707, you can achieve that by enabling the "Answer Manually" option of the Knowledge Agent
Then when the bot finds an answer from the KB, it will fill the
turn.KnowledgeAgent.answer
with the answer
Then you can display it, or use as an input for an AI Task to do further processing
And to check if the KB had an answer for the question, read the value of
turn.KnowledgeAgent.responded
, it is a boolean and its value will be either
true
or
false
r

rich-oxygen-43707

07/02/2023, 7:41 AM
Thank you. I have "answer manuallly" checked, and I am getting an answer to output on the fourth card on the Get-Question node, but then it goes to the GPT fallback so it seems the {{!turn.KnowledgeAgent.responded}} transition is not working as expected. It should evaluate to false since the agent did respond.
Here is an example in action. The "answer:" is from the knowledge agent, and of course the "GPT says:" is from the (incorrect) fallback to GPT. @early-train-33247
e

early-train-33247

07/02/2023, 9:40 PM
Hey @rich-oxygen-43707, try updating your condition to be just
!turn.KnowledgeAgent.responded
, instead of using {{}}
That may be the issue
If that doesn't work, you can update the condition to be
turn.KnowledgeAgent.answer === null
r

rich-oxygen-43707

07/02/2023, 9:41 PM
I believe I had it like that initially and it didn’t work, but I’ll try it again because I may be confused at this point. Thanks again
e

early-train-33247

07/02/2023, 9:41 PM
this might work then
I will check if the
responded
variable works as I am expecting
r

rich-oxygen-43707

07/03/2023, 3:03 PM
Yeah something is definitely not as expected. I have an Execute code immediately after my Raw Capture card. It is clearly showing that "answer" contains an answer but "responded" is false.
e

early-train-33247

07/04/2023, 1:01 AM
Okay then, my bad. The responded variable will be true only when the KB found an answer and responded manually
So try updating your code to be
!turn.KnowledgeAgent.answer
r

rich-oxygen-43707

07/04/2023, 3:23 AM
Yes, I have already changed to answer === null and of course that works. Thank you. It is good to know how the "responded" var is used.
e

early-train-33247

07/05/2023, 12:36 AM
Good to know it works! 🚀
Let me know if you need something else!