API を使用してエージェント データを更新する場合は、データ型全体を上書きするか、データ型の特定のフィールドのみを上書きします。通常、誤ってすべてのデータを上書きしないように、特定のフィールドを上書きすることをおすすめします。特定のフィールドを上書きするには、更新リクエストに FieldMask を指定します。
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);
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","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"],["翻訳に関する問題","translationIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2024-12-24 UTC。"],[],[]]