How to use the dialogflow.v2beta1.KnowledgeBasesClient function in dialogflow

To help you get started, we’ve selected a few dialogflow examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github googleapis / nodejs-dialogflow / samples / detect.v2beta1.js View on Github external
async function deleteKnowledgeBase(projectId, knowledgeBaseFullName) {
  // [START dialogflow_delete_knowledge_base]
  // Instantiate a DialogFlow client.
  const dialogflow = require('dialogflow').v2beta1;

  // Instantiate a DialogFlow KnowledgeBasesClient.
  const client = new dialogflow.KnowledgeBasesClient();

  /**
   * TODO(developer): Uncomment the following lines before running the sample.
   */
  // const projectId = 'ID of GCP project associated with your Dialogflow agent';
  // const knowledgeBaseFullName = `the full path of your knowledge base, e.g my-Gcloud-project/myKnowledgeBase`;

  const [result] = await client.deleteKnowledgeBase({
    name: knowledgeBaseFullName,
  });

  if (result.name === 'undefined') console.log(`Knowledge Base deleted`);
  // [END dialogflow_delete_knowledge_base]
}
github googleapis / nodejs-dialogflow / samples / detect.v2beta1.js View on Github external
async function getKnowledgeBase(projectId, knowledgeBaseId) {
  // [START dialogflow_get_knowledge_base]
  // Imports the Dialogflow client library
  const dialogflow = require('dialogflow').v2beta1;

  // Instantiate a DialogFlow client.
  const client = new dialogflow.KnowledgeBasesClient({
    projectId: projectId,
  });

  /**
   * TODO(developer): Uncomment the following lines before running the sample.
   */
  // const projectId = 'ID of GCP project associated with your Dialogflow agent';
  // const knowledgeBaseFullName = `the full path of your knowledge base, e.g my-Gcloud-project/myKnowledgeBase`;
  const formattedName = client.knowledgeBasePath(projectId, knowledgeBaseId);

  const [result] = await client.getKnowledgeBase({name: formattedName});
  console.log(`displayName: ${result.displayName}`);
  console.log(`name: ${result.name}`);
  // [END dialogflow_get_knowledge_base]
}
github googleapis / nodejs-dialogflow / samples / detect.v2beta1.js View on Github external
async function listKnowledgeBases(projectId) {
  // [START dialogflow_list_knowledge_base]
  // Imports the Dialogflow client library
  const dialogflow = require('dialogflow').v2beta1;

  // Instantiate a DialogFlow KnowledgeBasesClient.
  const client = new dialogflow.KnowledgeBasesClient({
    projectPath: projectId,
  });

  /**
   * TODO(developer): Uncomment the following lines before running the sample.
   */
  // const projectId = 'ID of GCP project associated with your Dialogflow agent';

  const formattedParent = client.projectPath(projectId);

  const [resources] = await client.listKnowledgeBases({
    parent: formattedParent,
  });
  resources.forEach(r => {
    console.log(`displayName: ${r.displayName}`);
    console.log(`name: ${r.name}`);
github googleapis / nodejs-dialogflow / samples / detect.v2beta1.js View on Github external
async function createKnowledgeBase(projectId, displayName) {
  // [START dialogflow_create_knowledge_base]
  // Imports the Dialogflow client library
  const dialogflow = require('dialogflow').v2beta1;

  // Instantiate a DialogFlow client.
  const client = new dialogflow.KnowledgeBasesClient();

  /**
   * TODO(developer): Uncomment the following lines before running the sample.
   */
  // const projectId = 'ID of GCP project associated with your Dialogflow agent';
  // const displayName = `your knowledge base display name, e.g. myKnowledgeBase`;

  const formattedParent = client.projectPath(projectId);
  const knowledgeBase = {
    displayName: displayName,
  };
  const request = {
    parent: formattedParent,
    knowledgeBase: knowledgeBase,
  };
github googleapis / nodejs-dialogflow / samples / detect.v2beta1.js View on Github external
// Instantiate a DialogFlow client.
  const sessionClient = new dialogflow.SessionsClient();

  /**
   * TODO(developer): Uncomment the following lines before running the sample.
   */
  // const projectId = 'ID of GCP project associated with your Dialogflow agent';
  // const sessionId = `user specific ID of session, e.g. 12345`;
  // const languageCode = 'BCP-47 language code, e.g. en-US';
  // const knowledgeBaseFullName = `the full path of your knowledge base, e.g my-Gcloud-project/myKnowledgeBase`;
  // const query = `phrase(s) to pass to detect, e.g. I'd like to reserve a room for six people`;

  // 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],