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.
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:
curl (Linux, macOS, or Cloud Shell)
Execute the following command:
curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "x-goog-user-project:PROJECT_ID " \
"https://REGION_ID -dialogflow.googleapis.com/v3/projects/PROJECT_ID /locations/REGION_ID /operations/OPERATION_ID "
PowerShell (Windows)
Execute the following command:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred"; "x-goog-user-project" = "PROJECT_ID " }
Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://REGION_ID -dialogflow.googleapis.com/v3/projects/PROJECT_ID /locations/REGION_ID /operations/OPERATION_ID " | Select-Object -Expand Content
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, ... }
To authenticate to Dialogflow, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
To authenticate to Dialogflow, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
To authenticate to Dialogflow, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.