API로 에이전트 데이터를 업데이트할 때 전체 데이터 유형을 덮어쓰거나 데이터 유형의 특정 필드만 덮어쓸 수 있습니다.
모든 데이터를 실수로 덮어쓰지 않도록 일반적으로 특정 필드를 덮어쓰는 것이 가장 좋습니다.
특정 필드를 덮어쓰려면 업데이트 요청에 FieldMask를 제공합니다.
다음 예시에서는 Intent 유형의 표시 이름을 업데이트하기 위해 FieldMask를 제공하는 방법을 보여줍니다.
CTS에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다.
자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.
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);}}}
Node.js
CTS에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다.
자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.
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();
Python
CTS에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다.
자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-04-14(UTC)"],[[["When using the API to update agent data, you have the option to either overwrite all data or modify only specific fields."],["It is generally recommended to update specific fields to prevent the accidental overwriting of all your data."],["To update specific fields, a `FieldMask` must be included in the update request to indicate the fields to be modified."],["The examples provided illustrate how to use a `FieldMask` to specifically update the display name for an `Intent` type across REST, Java, Node.js and Python."]]],[]]