Alguns métodos da API de agentes de conversação (Dialogflow CX) retornam uma operação de longa duração. Esses métodos são assíncronos e a operação pode não ser concluída quando o método retornar uma resposta. Você pode verificar o status, aguardar a conclusão ou cancelar operações.
Aguardar a conclusão de uma operação
Confira a seguir como aguardar a conclusão de uma operação.
REST
Para pesquisar o status de uma operação, chame o método get
para o
Operations
recurso.
Quando a operação for concluída,
o campo done
será definido como verdadeiro.
Antes de usar os dados da solicitação abaixo, faça as substituições a seguir:
- REGION_ID: o ID da sua região
- PROJECT_ID: o ID do projeto do Google Cloud
- OPERATION_ID: ID da operação
Método HTTP e URL:
GET https://REGION_ID-dialogflow.googleapis.com/v3/projects/PROJECT_ID/locations/REGION_ID/operations/OPERATION_ID
Para enviar a solicitação, expanda uma destas opções:
Você receberá uma resposta JSON semelhante a esta:
{ "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
Para autenticar no Dialogflow, configure o Application Default Credentials. Para mais informações, consulte Configurar a autenticação para um ambiente de desenvolvimento local.
Node.js
Para autenticar no Dialogflow, configure o Application Default Credentials. Para mais informações, consulte Configurar a autenticação para um ambiente de desenvolvimento local.
Python
Para autenticar no Dialogflow, configure o Application Default Credentials. Para mais informações, consulte Configurar a autenticação para um ambiente de desenvolvimento local.