Algunos productos y funciones están en proceso de cambiar de nombre. Las funciones de flujo y de la guía generativa también se migrarán a una sola consola consolidada. Consulta los detalles.
Organiza tus páginas con colecciones
Guarda y categoriza el contenido según tus preferencias.
Por lo general, los agentes se crean y borran mediante la consola.
Sin embargo, en ciertas situaciones avanzadas, puede que te resulte más fácil usar la API.
Crea un agente
En los siguientes ejemplos, se muestra cómo llamar al método Create para el tipo Agent.
Selecciona un protocolo y una versión para la Referencia del agente:
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;}}}
[[["Fácil de comprender","easyToUnderstand","thumb-up"],["Resolvió mi problema","solvedMyProblem","thumb-up"],["Otro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Información o código de muestra incorrectos","incorrectInformationOrSampleCode","thumb-down"],["Faltan la información o los ejemplos que necesito","missingTheInformationSamplesINeed","thumb-down"],["Problema de traducción","translationIssue","thumb-down"],["Otro","otherDown","thumb-down"]],["Última actualización: 2025-09-04 (UTC)"],[[["\u003cp\u003eThis page outlines how to create and delete Dialogflow CX agents using the API, which is useful for advanced scenarios beyond the console's capabilities.\u003c/p\u003e\n"],["\u003cp\u003eThe 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.\u003c/p\u003e\n"],["\u003cp\u003eTo 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 \u003ccode\u003ecurl\u003c/code\u003e for Linux/macOS/Cloud Shell and PowerShell for Windows.\u003c/p\u003e\n"],["\u003cp\u003eTo 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 \u003ccode\u003ecurl\u003c/code\u003e for Linux/macOS/Cloud Shell and PowerShell for Windows.\u003c/p\u003e\n"],["\u003cp\u003eThe 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.\u003c/p\u003e\n"]]],[],null,[]]