hi,
I am trying to add the knowledge beta but I am getting an error
UnhandledPromiseRejectionWarning: TypeError: match error: could not instantiate a path template from projects/botkit-a4598/knowledgeBases/projects/botkit-a4598/knowledgeBases/NzU0ODk2NTM2LOMzMzMwNTM0NA
at PathTemplate.match (/home/****/project/demo/node_modules/google-gax/build/src/pathTemplate.js:99:19)
const dialogflow = require('dialogflow');
const uuid = require('uuid');
module.exports = {
know:async function(
projectId,
sessionId,
languageCode,
knowledgeBaseFullName,
query,
error
) {
// [START dialogflow_detect_intent_knowledge]
// Imports the Dialogflow client library
const dialogflow = require('dialogflow').v2beta1;
// Instantiate a DialogFlow client.
const sessionClient = new dialogflow.SessionsClient();
projectId = 'botkit-a4598fgh';
sessionId = `12345`;
languageCode = 'en-US';
knowledgeBaseFullName = `projects/botkit-a4598fgh/knowledgeBases/NzU0ODk2NTM2MTMzMzMwNTM0NA`;
query = `How can I track my orders & payment?`;
// Define session path
const sessionPath = sessionClient.sessionPath(projectId, sessionId);
const knowbase = new dialogflow.KnowledgeBasesClient();
const knowledgeBasePath = knowbase.knowledgeBasePath(
projectId,
knowledgeBaseFullName
);
// The audio query request
const request = {
session: sessionPath,
queryInput: {
text: {
text: query,
languageCode: languageCode,
},
},
queryParams: {
knowledgeBaseNames: [knowledgeBasePath],
},
}
if(error)
{
console.log(error);
}
const responses = await sessionClient.detectIntent(request);
const result = responses[0].queryResult;
console.log(`Query text: ${result.queryText}`);
console.log(`Detected Intent: ${result.intent.displayName}`);
console.log(`Confidence: ${result.intentDetectionConfidence}`);
console.log(`Query Result: ${result.fulfillmentText}`);
const answers = result.knowledgeAnswers.answers;
console.log(`There are ${answers.length} anwser(s);`);
answers.forEach(a => {
console.log(` answer: ${a.answer}`);
console.log(` confidence: ${a.matchConfidence}`);
console.log(` match confidence level: ${a.matchConfidenceLevel}`);
});
// [END dialogflow_detect_intent_knowledge]
}
}
please help me
thanks
Hi @sarigasurendranms it looks like there's an issue with how you're calling knowledgeBasePath(). In your example you're passing the full name as the second parameter but it is expecting just NzU0ODk2NTM2MTMzMzMwNTM0NA.
Most helpful comment
Hi @sarigasurendranms it looks like there's an issue with how you're calling
knowledgeBasePath(). In your example you're passing the full name as the second parameter but it is expecting justNzU0ODk2NTM2MTMzMzMwNTM0NA.