Some methods of the Conversational Agents (Dialogflow CX) API return a long-running operation. These methods are asynchronous, and the operation may not be completed when the method returns a response. You can check on the status, wait for completion, or cancel operations.
Wait for an operation to complete
The following shows how to wait for an operation to complete.
REST
To poll an operation's status, call the get
method for the
Operations
resource.
When the operation has completed,
the done
field is set to true.
Before using any of the request data, make the following replacements:
- REGION_ID: your region ID
- PROJECT_ID: your Google Cloud project ID
- OPERATION_ID: your operation ID
HTTP method and URL:
GET https://REGION_ID-dialogflow.googleapis.com/v3/projects/PROJECT_ID/locations/REGION_ID/operations/OPERATION_ID
To send your request, expand one of these options:
You should receive a JSON response similar to the following:
{ "name": "projects/PROJECT_ID/locations/REGION_ID/operations/OPERATION_ID", "metadata": { "@type": "type.googleapis.com/google.cloud.dialogflow.v3.SomeOperationType", "state": "DONE" }, "done": true, ... }
Java
To authenticate to Dialogflow, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Node.js
To authenticate to Dialogflow, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Python
To authenticate to Dialogflow, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.