CTS에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다.
자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.
importcom.google.cloud.dialogflow.cx.v3.Agent;importcom.google.cloud.dialogflow.cx.v3.Agent.Builder;importcom.google.cloud.dialogflow.cx.v3.AgentsClient;importcom.google.cloud.dialogflow.cx.v3.AgentsSettings;importjava.io.IOException;publicclassCreateAgent{publicstaticvoidmain(String[]args)throwsIOException{// TODO(developer): Replace these variables before running the sample.StringprojectId="my-project-id";StringdisplayName="my-display-name";createAgent(projectId,displayName);}publicstaticAgentcreateAgent(Stringparent,StringdisplayName)throwsIOException{StringapiEndpoint="global-dialogflow.googleapis.com:443";AgentsSettingsagentsSettings=AgentsSettings.newBuilder().setEndpoint(apiEndpoint).build();// Note: close() needs to be called on the AgentsClient object to clean up resources// such as threads. In the example below, try-with-resources is used,// which automatically calls close().try(AgentsClientclient=AgentsClient.create(agentsSettings)){// Set the details of the Agent to createBuilderbuild=Agent.newBuilder();build.setDefaultLanguageCode("en");build.setDisplayName(displayName);// Correct format for timezone is location/city// For example America/Los_Angeles, Europe/Madrid, Asia/Tokyobuild.setTimeZone("America/Los_Angeles");Agentagent=build.build();StringparentPath=String.format("projects/%s/locations/%s",parent,"global");// Calls the create agent api and returns the created AgentAgentresponse=client.createAgent(parentPath,agent);System.out.println(response);returnresponse;}}}
Node.js
CTS에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다.
자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.
constparent='projects/'+projectId+'/locations/global';constapi_endpoint='global-dialogflow.googleapis.com';constagent={displayName:displayName,defaultLanguageCode:'en',timeZone:'America/Los_Angeles',};const{AgentsClient}=require('@google-cloud/dialogflow-cx');constclient=newAgentsClient({apiEndpoint:api_endpoint});asyncfunctionsetAgentSample(){constrequest={agent,parent,};const[response]=awaitclient.createAgent(request);console.log(`response: ${JSON.stringify(response,null,2)}`);// Delete created agent resourceclient.deleteAgent({name:response.name});}awaitsetAgentSample();
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)"],[[["This page outlines how to create and delete Dialogflow CX agents using the API, which is useful for advanced scenarios beyond the console's capabilities."],["The API references for creating and deleting agents are available in REST and RPC protocols, along with specific client libraries for C++, C#, Go, Java, Node.js, and Python, providing comprehensive options for integration."],["To create an agent via REST, you need to send a POST request to a specified URL, including details like display name, default language, and time zone, with provided code examples using `curl` for Linux/macOS/Cloud Shell and PowerShell for Windows."],["To delete an agent via REST, you must send a DELETE request to the relevant agent's URL, requiring your project ID, region ID, and the agent's ID, with provided code examples using `curl` for Linux/macOS/Cloud Shell and PowerShell for Windows."],["The examples provided in Java, Node.js, and Python offer detailed code snippets and instructions for creating agents through their respective client libraries, including necessary authentication steps using Application Default Credentials."]]],[]]