| 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 | |