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.
Einige Methoden der Konversations-Agents (Dialogflow CX) API lösen einen lang andauernden Vorgang aus.
Diese Methoden sind asynchron und der Vorgang ist möglicherweise noch nicht abgeschlossen, wenn die Methode eine Antwort zurückgibt.
Sie können den Status prüfen, auf den Abschluss warten oder Vorgänge abbrechen.
Auf Abschluss eines Vorgangs warten
Im Folgenden wird gezeigt, wie Sie auf den Abschluss eines Vorgangs warten.
REST
Wenn Sie den Status eines Vorgangs abfragen möchten, rufen Sie die Methode get für die Ressource Operations auf.
Wenn der Vorgang abgeschlossen ist, wird das Feld done auf „true“ gesetzt.
Ersetzen Sie diese Werte in den folgenden Anfragedaten:
importcom.google.api.gax.longrunning.OperationFuture;importcom.google.cloud.dialogflow.cx.v3.AgentName;importcom.google.cloud.dialogflow.cx.v3.AgentsClient;importcom.google.cloud.dialogflow.cx.v3.AgentsSettings;importcom.google.cloud.dialogflow.cx.v3.ExportAgentRequest;importcom.google.cloud.dialogflow.cx.v3.ExportAgentResponse;importcom.google.protobuf.Struct;importjava.io.IOException;importjava.util.concurrent.ExecutionException;publicclassExportAgent{publicstaticvoidmain(String[]args)throwsIOException,InterruptedException,ExecutionException{// TODO(developer): Replace these variables before running the sample.StringprojectId="my-project-id";StringagentId="my-agent-id";Stringlocation="my-location";exportAgent(projectId,agentId,location);}publicstaticvoidexportAgent(StringprojectId,StringagentId,Stringlocation)throwsIOException,InterruptedException,ExecutionException{// Sets the api endpoint to specified locationStringapiEndpoint=String.format("%s-dialogflow.googleapis.com:443",location);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(AgentsClientagentsClient=AgentsClient.create(agentsSettings)){ExportAgentRequestrequest=ExportAgentRequest.newBuilder().setName(AgentName.of(projectId,location,agentId).toString()).build();// Returns a future of the operationOperationFuture<ExportAgentResponse,Struct>future=agentsClient.exportAgentOperationCallable().futureCall(request);// get the export agent response after the operation is completedExportAgentResponseresponse=future.get();System.out.println(response);}}}
const{AgentsClient,protos}=require('@google-cloud/dialogflow-cx');constapi_endpoint=`${location}-dialogflow.googleapis.com`;constclient=newAgentsClient({apiEndpoint:api_endpoint});constexportAgentRequest=newprotos.google.cloud.dialogflow.cx.v3.ExportAgentRequest();exportAgentRequest.name=`projects/${projectId}/locations/${location}/agents/${agentId}`;// exportAgent call returns a promise to a long running operationconst[operation]=awaitclient.exportAgent(exportAgentRequest);// Waiting for the long running opporation to finishconst[response]=awaitoperation.promise();// Prints the result of the operation when the operation is doneconsole.log(response);
fromgoogle.cloud.dialogflowcx_v3.services.agents.clientimportAgentsClientfromgoogle.cloud.dialogflowcx_v3.types.agentimportExportAgentRequestdefexport_long_running_agent(project_id,agent_id,location):api_endpoint=f"{location}-dialogflow.googleapis.com:443"client_options={"api_endpoint":api_endpoint}agents_client=AgentsClient(client_options=client_options)export_request=ExportAgentRequest()export_request.name=(f"projects/{project_id}/locations/{location}/agents/{agent_id}")# export_agent returns a long running operationoperation=agents_client.export_agent(request=export_request)# Returns the result of the operation when the operation is donereturnoperation.result()
[[["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-14 (UTC)."],[[["Some Dialogflow CX API methods involve long-running operations that are asynchronous and may not be immediately completed upon method return."],["You can monitor the status of these operations by using the `get` method on the `Operations` resource, where the `done` field indicates completion."],["When checking multiple operations, consider implementing rate limiting or use the `list` method to manage calls effectively."],["To wait for an operation to complete, utilize the `get` method (REST), `future.get()` (Java), `operation.promise()` (Node.js), or `operation.result()` (Python), depending on the language being used."],["The code examples in REST, Java, Node.js and Python illustrate how to make requests to the API and how to handle long-running operations."]]],[]]