How to use the dialogflow.v2beta1.DocumentsClient 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 deleteDocument(projectId, documentId) {
  // [START dialogflow_delete_document]
  // Imports the Dialogflow client library
  const dialogflow = require('dialogflow').v2beta1;

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

  /**
   * TODO(developer): Uncomment the following lines before running the sample.
   */
  // const projectId = 'ID of GCP project associated with your Dialogflow agent';
  // const documentId = `full path to document in knowledge base, e.g. myKnowledgeBase/documents/myDoc`;

  const [operation] = await client.deleteDocument({name: documentId});
  const responses = await operation.promise();
  if (responses[2].done === true) console.log(`document deleted`);
  // [END dialogflow_delete_document]
}
github googleapis / nodejs-dialogflow / samples / detect.v2beta1.js View on Github external
async function listDocuments(projectId, knowledgeBaseFullName) {
  // [START dialogflow_list_document]
  // Imports the Dialogflow client library
  const dialogflow = require('dialogflow').v2beta1;

  // Instantiate a DialogFlow Documents client.
  const client = new dialogflow.DocumentsClient({
    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 [resources] = await client.listDocuments({
    parent: knowledgeBaseFullName,
  });
  console.log(
    `There are ${resources.length} documents in ${knowledgeBaseFullName}`
  );
  resources.forEach(resource => {
github googleapis / nodejs-dialogflow / samples / detect.v2beta1.js View on Github external
async function getDocument(documentId) {
  // [START dialogflow_get_document]
  // Imports the Dialogflow client library
  const dialogflow = require('dialogflow').v2beta1;

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

  /**
   * TODO(developer): Uncomment the following lines before running the sample.
   */
  // const documentId = `full path to document in knowledge base, e.g. myKnowledgeBase/documents/myDoc`;

  const [r] = await client.getDocument({name: documentId});
  console.log(` KnowledgeType: ${r.knowledgeType}`);
  console.log(` displayName: ${r.displayName}`);
  console.log(` mimeType: ${r.mimeType}`);
  console.log(` contentUri: ${r.contentUri}`);
  console.log(` source: ${r.source}`);
  console.log(` name: ${r.name}`);
  // [END dialogflow_get_document]
github googleapis / nodejs-dialogflow / samples / detect.v2beta1.js View on Github external
async function createDocument(
  projectId,
  knowledgeBaseFullName,
  documentPath,
  documentName,
  knowledgeTypes,
  mimeType
) {
  // [START dialogflow_create_document]
  // Imports the Dialogflow client library
  const dialogflow = require('dialogflow').v2beta1;

  // Instantiate a DialogFlow Documents client.
  const client = new dialogflow.DocumentsClient({
    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 documentPath = `path of the document you'd like to add, e.g. https://dialogflow.com/docs/knowledge-connectors`;
  // const documentName = `displayed name of your document in knowledge base, e.g. myDoc`;
  // const knowledgeTypes = `The Knowledge type of the Document. e.g. FAQ`;
  // const mimeType = `The mime_type of the Document. e.g. text/csv, text/html,text/plain, text/pdf etc.`;

  const request = {
    parent: knowledgeBaseFullName,
    document: {