Update data with a FieldMask

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 and events for an Intents type.

REST

Supply the updateMask URL query parameter for the patch method. For example:

?updateMask=displayName,events
    

C#

Supply the updateMask parameter for the UpdateIntent method. For example, to create an update mask:

FieldMask updateMask = new FieldMask();
updateMask.Paths.AddRange(new string[] { "display_name", "events" });
    

Go

Supply the UpdateIntentRequest.UpdateMask field for the UpdateIntent method. For example, to create an update mask:

import dialogflowpb "google.golang.org/genproto/googleapis/cloud/dialogflow/v2"
...
updateMask := &dialogflowpb.FieldMask{
  Paths: []string{"display_name", "events"},
}
    

Java

Supply the UpdateIntentRequest.UpdateMask field for the updateIntent method. For example, to create an update mask:

FieldMask fieldMask =
  FieldMask.newBuilder()
    .addPaths("display_name")
    .addPaths("events")
    .build();
    

Node.js

Supply the request.updateMask parameter for the updateIntent function. For example, to create an update mask:

var updateMask = {
  'paths': [
    'display_name',
    'events'
  ]
};
    

PHP

Supply the optionalArgs.updateMask parameter for the UpdateIntent method. For example, to create an update mask:

use Google\Protobuf\FieldMask;
...
$updateMask = new FieldMask([
  'paths' => ['displayName', 'events']
]);
    

Python

Supply the update_mask parameter for the update_intent method. For example, to create an update mask:

from google.protobuf import field_mask_pb2
...
update_mask = field_mask_pb2.FieldMask(paths=['display_name', 'events'])
    

Ruby

Supply the update_mask parameter for the update_intent function. For example, to create an update mask:

mask = Google::Protobuf::FieldMask.new
mask.path = ["display_name", "events"]