Some products and features are in the process of being renamed. Generative playbook and flow features are also being migrated to a single consolidated console. See the details.
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 Intent type.
Select a protocol and version for the Intent reference:
importcom.google.cloud.dialogflow.cx.v3.Intent;importcom.google.cloud.dialogflow.cx.v3.Intent.Builder;importcom.google.cloud.dialogflow.cx.v3.IntentsClient;importcom.google.cloud.dialogflow.cx.v3.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";StringagentId="my-agent-id";StringintentId="my-intent-id";Stringlocation="my-location";StringdisplayName="my-display-name";updateIntent(projectId,agentId,intentId,location,displayName);}// DialogFlow API Update Intent sample.publicstaticvoidupdateIntent(StringprojectId,StringagentId,StringintentId,Stringlocation,StringdisplayName)throwsIOException{// Note: close() needs to be called on the IntentsClient object to clean up resources// such as threads. In the example below, try-with-resources is used,// which automatically calls close().try(IntentsClientclient=IntentsClient.create()){StringintentPath="projects/"
projectId"/locations/"
location"/agents/"
agentId"/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-cx');constintentClient=newIntentsClient();//TODO(developer): Uncomment these variables before running the sample.// const projectId = 'your-project-id';// const agentId = 'your-agent-id';// const intentId = 'your-intent-id';// const location = 'your-location';// const displayName = 'your-display-name';asyncfunctionupdateIntent(){constagentPath=intentClient.projectPath(projectId);constintentPath=`${agentPath}/locations/${location}/agents/${agentId}/intents/${intentId}`;//Gets the intent from intentPathconstintent=awaitintentClient.getIntent({name:intentPath});intent[0].displayName=displayName;//Specifies what is being updatedconstupdateMask={paths:['display_name'],};constupdateIntentRequest={intent:intent[0],updateMask,languageCode:'en',};//Send the request for update the intent.constresult=awaitintentClient.updateIntent(updateIntentRequest);console.log(result);}updateIntent();