Stay organized with collections
Save and categorize content based on your preferences.
When updating agent data with the API,
you can choose to overwrite the entire data type
or to overwrite only specific fields of the data type.
It is usually best to overwrite specific fields,
so you avoid accidentally overwriting all of your data.
To overwrite specific fields,
supply a
FieldMask
to your update request.
The following examples show how to supply a FieldMask
to update the display name for an
Intents
type.
REST
Supply the updateMask
URL query parameter for the patch method.
For example:
importcom.google.cloud.dialogflow.v2.Intent;importcom.google.cloud.dialogflow.v2.Intent.Builder;importcom.google.cloud.dialogflow.v2.IntentsClient;importcom.google.cloud.dialogflow.v2.UpdateIntentRequest;importcom.google.protobuf.FieldMask;importjava.io.IOException;publicclassUpdateIntent{publicstaticvoidmain(String[]args)throwsIOException{// TODO(developer): Replace these variables before running the sample.StringprojectId="my-project-id";StringintentId="my-intent-id";Stringlocation="my-location";StringdisplayName="my-display-name";updateIntent(projectId,intentId,location,displayName);}// DialogFlow API Update Intent sample.publicstaticvoidupdateIntent(StringprojectId,StringintentId,Stringlocation,StringdisplayName)throwsIOException{try(IntentsClientclient=IntentsClient.create()){StringintentPath="projects/"+projectId+"/locations/"+location+"/agent/intents/"+intentId;BuilderintentBuilder=client.getIntent(intentPath).toBuilder();intentBuilder.setDisplayName(displayName);FieldMaskfieldMask=FieldMask.newBuilder().addPaths("display_name").build();Intentintent=intentBuilder.build();UpdateIntentRequestrequest=UpdateIntentRequest.newBuilder().setIntent(intent).setLanguageCode("en").setUpdateMask(fieldMask).build();// Make API request to update intent using fieldmaskIntentresponse=client.updateIntent(request);System.out.println(response);}}}
const{IntentsClient}=require('@google-cloud/dialogflow');constintentClient=newIntentsClient();constagentPath=intentClient.projectAgentPath(projectId);constintentPath=agentPath+'/intents/'+intentId;constintent=awaitintentClient.getIntent({name:intentPath});intent[0].displayName=displayName;constupdateMask={paths:['display_name'],};constupdateIntentRequest={intent:intent[0],updateMask:updateMask,languageCode:'en',};//Send the request for update the intent.constresult=awaitintentClient.updateIntent(updateIntentRequest);console.log(result);
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-21 UTC."],[[["\u003cp\u003eWhen updating agent data via the API, you can choose to overwrite either the entire data type or specific fields within it.\u003c/p\u003e\n"],["\u003cp\u003eOverwriting specific fields using a \u003ccode\u003eFieldMask\u003c/code\u003e is generally recommended to avoid accidental data loss.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eupdateMask\u003c/code\u003e parameter, supplied either as a URL query parameter in REST or through a dedicated object in the code, specifies which fields to update.\u003c/p\u003e\n"],["\u003cp\u003eThe provided examples demonstrate how to use \u003ccode\u003eFieldMask\u003c/code\u003e to update the display name of an Intent for REST, Java, Node.js, and Python.\u003c/p\u003e\n"],["\u003cp\u003eApplication Default Credentials are required for authentication to Dialogflow, with instructions available for local development environments.\u003c/p\u003e\n"]]],[],null,[]]