| 18 | const util = require('util'); |
| 19 | |
| 20 | async function createKnowledgeBase(projectId, displayName) { |
| 21 | // [START dialogflow_create_knowledge_base] |
| 22 | // Imports the Dialogflow client library |
| 23 | const dialogflow = require('@google-cloud/dialogflow').v2beta1; |
| 24 | |
| 25 | // Instantiate a DialogFlow client. |
| 26 | const client = new dialogflow.KnowledgeBasesClient(); |
| 27 | |
| 28 | /** |
| 29 | * TODO(developer): Uncomment the following lines before running the sample. |
| 30 | */ |
| 31 | // const projectId = 'ID of GCP project associated with your Dialogflow agent'; |
| 32 | // const displayName = `your knowledge base display name, e.g. myKnowledgeBase`; |
| 33 | |
| 34 | const formattedParent = 'projects/' + projectId; |
| 35 | const knowledgeBase = { |
| 36 | displayName: displayName, |
| 37 | }; |
| 38 | const request = { |
| 39 | parent: formattedParent, |
| 40 | knowledgeBase: knowledgeBase, |
| 41 | }; |
| 42 | |
| 43 | const [result] = await client.createKnowledgeBase(request); |
| 44 | console.log(`Name: ${result.name}`); |
| 45 | console.log(`displayName: ${result.displayName}`); |
| 46 | |
| 47 | // [END dialogflow_create_knowledge_base] |
| 48 | } |
| 49 | |
| 50 | /* |
| 51 | *This test is commented until the proto change for dialogflow/v2beta1 is finished. |