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.
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;}}}
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","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"],["Other","otherDown","thumb-down"]],["Last updated 2025-03-21 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."]]],[]]