How to get list of all user questions from Bot Ontology automatically

Is there any way by which I can provide all list of User Questions from Bot Ontology. Suppose User types a query “What are your capabilities?” or “Which questions you can answer?”. As a response from bot I want to list down all the question I have defined in Bot Ontology as User Question.

The bot should fetch and show the list of all the questions automatically, so that next time if I update or add new questions in Bot Ontology then Bot automatically list down those updated User Questions.

By this user can go through that list of questions which Bot can answer and user can directly select either its number or copy paste the question itself to know its answer.

@himanshu.goel.mca Knowledge base usually have huge list of questions (May be in hundreds) and I guess it might not be appropriate listing all the FAQs .

However, to achieve your usecase I have followed the below steps:

  1. Exported the Knowledge to JSON file

  1. Created a dialog as list of faqs

  2. Added a script node in the dialog in which I have created a context variable to store the JSON of Knowledge graph.

  1. Added the entity node of type - List of values (enumerated) with reference to the context data for fetching the question and enabled channel specific formatting.

  1. Trained the dialog list of faqs with the utterances like “FAQ list”, “Frequently asked questions”.

So now, when user utters “Frequently asked questions”, the dialog “list of faqs” will be invoked and it list all the questions.

Hope this could be of some help :slight_smile:

Thanks @Subrahmanyam for you reply, you have explained the solution very well. The only thing issue which I found is that everytime we make changes in knowledge based, we need to again export that data and make it updated in the list of context.

Is there any way by which we can avoid it, means if this list of faq can be updated automatically based on the data present in knowledge collection?

@himanshu.goel.mca Thank you.

I will check if we have a public API which fetches the list of tasks or FAQs or will take this up with the product management team and proceed with their inputs accordingly.

Will keep you posted.

@himanshu.goel.mca We currently do not have public APIs for fetching list of tasks or FAQs. I will check with Product Management team if we would need to create some and make them available in future releases.

Thus said, as mentioned earlier, FAQs of system wouldn’t change quite often. So maybe, we should be good with using the KG JSON at a dialog . Developer could even add these sort of questions in the KG at the Root node or a nodes having term usage as organizer and could present all FAQs or FAQs of a category to the user using advanced JS editor.

Please refer to below link related to term usage options at Knowledge Graph for more details:
https://developer.kore.ai/docs/bots/bot-builder/defining-bot-tasks/kore-ai-knowledge-graph/creating-a-knowledge-graph/

2 Likes

Thanks @Subrahmanyam. Using the KG at the root node also requires to update the all FAQs list in JS editor every time whenever we add some new FAQ in the system.

So for now we will refer the approach you suggested, and maybe in future you product development team can take this as a new feature accordingly.

1 Like

Hi Himanshu, this is a great topic, I know too late, but I was able to use the Kore.AI API to automatically get the list of all the questions on the bot.
The first point is to implement a proper JWT mechanism. In my case, I 've updated the code provided by Kore with a second function. If you call this API with /app you will get the JWT token without the timestamp (required for the API).

router.post(’/app’, function(req, res, next) {
console.log(req.body);
var clientSecret = req.body.clientSecret;
var options = {
“appId”:req.body.appId};
console.log(options);
var token = jwt.sign(options, clientSecret,{noTimestamp:true});
res.send({“jwt”:token});
});

Then, you can design a dialog that looks like the following:
image

The first script is just preparing the fields botId, clientSecret, etc.
The getJWT service is contacting our internal webservice where we implement the JWT.
then, we get the list of knowledge tasks (using this api)

The answer to that web service is the taxonomy of your knowledge base.
The script process KBTasks is getting the following data:

  • ktId, the knowledge Task id from the field _id
  • nodeId, the identifier of the parent node you want to obtain all child elements.

This is the code from the script:

var kb = context.GetKBTasks.response.body[0].taxonomy;

context.ktId = context.GetKBTasks.response.body[0]["_id"];
context.nodeId = null;

for (var i in kb){
if (kb[i].label === context.topic){
context.nodeId = kb[i].nodeId;
break;
}
}

Finally, we invoke the getFAQS api to fetch the questions and answers of the knowledge base.
To show the questions to the end user, we are using the FullKB message node, with the following script:

var questions = [];

for (var i in context.GetFAQS.response.body.faqs){
questions.push(context.GetFAQS.response.body.faqs[i].questionPayload.question);
}
//context.GetFAQS.response.faqs[i].questionPayload.question
print(JSON.stringify(questions));