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