| 17 | process.env.DEBUG = 'dialogflow:debug'; // enables lib debugging statements |
| 18 | |
| 19 | async function main(projectId, intentId, displayName) { |
| 20 | // [START dialogflow_update_intent_sample] |
| 21 | const {IntentsClient} = require('@google-cloud/dialogflow'); |
| 22 | |
| 23 | const intentClient = new IntentsClient(); |
| 24 | |
| 25 | const agentPath = intentClient.projectAgentPath(projectId); |
| 26 | const intentPath = agentPath + '/intents/' + intentId; |
| 27 | |
| 28 | const intent = await intentClient.getIntent({name: intentPath}); |
| 29 | intent[0].displayName = displayName; |
| 30 | const updateMask = { |
| 31 | paths: ['display_name'], |
| 32 | }; |
| 33 | |
| 34 | const updateIntentRequest = { |
| 35 | intent: intent[0], |
| 36 | updateMask: updateMask, |
| 37 | languageCode: 'en', |
| 38 | }; |
| 39 | |
| 40 | //Send the request for update the intent. |
| 41 | const result = await intentClient.updateIntent(updateIntentRequest); |
| 42 | console.log(result); |
| 43 | // [END dialogflow_update_intent_sample] |
| 44 | } |
| 45 | |
| 46 | process.on('unhandledRejection', err => { |
| 47 | console.error(err.message); |