(projectId, agentId, intentId, location, displayName)
| 15 | 'use strict'; |
| 16 | |
| 17 | async function main(projectId, agentId, intentId, location, displayName) { |
| 18 | // [START dialogflow_cx_update_intent] |
| 19 | |
| 20 | const {IntentsClient} = require('@google-cloud/dialogflow-cx'); |
| 21 | |
| 22 | const intentClient = new IntentsClient(); |
| 23 | |
| 24 | //TODO(developer): Uncomment these variables before running the sample. |
| 25 | // const projectId = 'your-project-id'; |
| 26 | // const agentId = 'your-agent-id'; |
| 27 | // const intentId = 'your-intent-id'; |
| 28 | // const location = 'your-location'; |
| 29 | // const displayName = 'your-display-name'; |
| 30 | |
| 31 | async function updateIntent() { |
| 32 | const agentPath = intentClient.projectPath(projectId); |
| 33 | const intentPath = `${agentPath}/locations/${location}/agents/${agentId}/intents/${intentId}`; |
| 34 | |
| 35 | //Gets the intent from intentPath |
| 36 | const intent = await intentClient.getIntent({name: intentPath}); |
| 37 | intent[0].displayName = displayName; |
| 38 | |
| 39 | //Specifies what is being updated |
| 40 | const updateMask = { |
| 41 | paths: ['display_name'], |
| 42 | }; |
| 43 | |
| 44 | const updateIntentRequest = { |
| 45 | intent: intent[0], |
| 46 | updateMask, |
| 47 | languageCode: 'en', |
| 48 | }; |
| 49 | |
| 50 | //Send the request for update the intent. |
| 51 | const result = await intentClient.updateIntent(updateIntentRequest); |
| 52 | console.log(result); |
| 53 | } |
| 54 | |
| 55 | updateIntent(); |
| 56 | |
| 57 | // [END dialogflow_cx_update_intent] |
| 58 | } |
| 59 | |
| 60 | process.on('unhandledRejection', err => { |
| 61 | console.error(err.message); |
no test coverage detected