MCPcopy Create free account
hub / github.com/GoogleCloudPlatform/nodejs-docs-samples / main

Function main

dialogflow/list-intents.js:21–72  ·  view source on GitHub ↗

* List of all intents in the specified project. * @param {string} projectId The project to be used

(projectId = 'YOUR_PROJECT_ID')

Source from the content-addressed store, hash-verified

19 * @param {string} projectId The project to be used
20 */
21function main(projectId = 'YOUR_PROJECT_ID') {
22 // [START dialogflow_list_intents]
23
24 /**
25 * TODO(developer): Uncomment the following lines before running the sample.
26 */
27 // const projectId = 'The Project ID to use, e.g. 'YOUR_GCP_ID';
28
29 // Imports the Dialogflow library
30 const dialogflow = require('@google-cloud/dialogflow');
31
32 // Instantiates clients
33 const intentsClient = new dialogflow.IntentsClient();
34
35 async function listIntents() {
36 // Construct request
37
38 // The path to identify the agent that owns the intents.
39 const projectAgentPath = intentsClient.projectAgentPath(projectId);
40
41 console.log(projectAgentPath);
42
43 const request = {
44 parent: projectAgentPath,
45 };
46
47 // Send the request for listing intents.
48 const [response] = await intentsClient.listIntents(request);
49 response.forEach(intent => {
50 console.log('====================');
51 console.log(`Intent name: ${intent.name}`);
52 console.log(`Intent display name: ${intent.displayName}`);
53 console.log(`Action: ${intent.action}`);
54 console.log(`Root folowup intent: ${intent.rootFollowupIntentName}`);
55 console.log(`Parent followup intent: ${intent.parentFollowupIntentName}`);
56
57 console.log('Input contexts:');
58 intent.inputContextNames.forEach(inputContextName => {
59 console.log(`\tName: ${inputContextName}`);
60 });
61
62 console.log('Output contexts:');
63 intent.outputContexts.forEach(outputContext => {
64 console.log(`\tName: ${outputContext.name}`);
65 });
66 });
67 }
68
69 listIntents();
70
71 // [END dialogflow_list_intents]
72}
73
74main(...process.argv.slice(2));

Callers 1

list-intents.jsFile · 0.70

Calls 1

listIntentsFunction · 0.70

Tested by

no test coverage detected