Einige Produkte und Funktionen werden derzeit umbenannt. Auch die Funktionen für generative Playbooks und Abläufe werden zu einer einzigen konsolidierten Console migriert. Weitere Informationen
Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Normalerweise erstellen und löschen Sie Agents mit der Konsole.
In bestimmten erweiterten Szenarien ist es jedoch möglicherweise einfacher, die API zu verwenden.
Agent erstellen
Die folgenden Beispiele zeigen, wie die Methode Create für den Typ Agent aufgerufen wird.
Wählen Sie ein Protokoll und eine Version für die Agent-Referenz aus:
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;}}}
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-04-03 (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."]]],[]]