I’m making a bot that basically answers FAQ using a knowledge base source. I’m kind of lost on how to add a fallback for when the knowledge base query does’t find an answer. Is there a way for me to check if the knowledge base query didn’t find an answer?
Yes, whenever you are looking fo something, always check the “JSON” tab. It contains all the information/payload that the bot is processing.
In your case you can have a condition like:
event.nlu.elected_facts.length > 0 && event.nlu.elected_facts[0].id != 'dont_know' && event.nlu.elected_facts[0].confidence > 0.5
So event.nlu.elected_facts.length
check if there is a fact/KB entry is detected
Then making sure it is not “I don’t know” using event.nlu.elected_facts[0].id != 'dont_know'
Then making sure that this elected fact has a confidence of more than 50%