'Why is Dialogflow CX referencing gcloud's project (project-number)?

I am working the Dialogflow CX Java SDK to execute a list agents command. When, I try to list the agents, I get this exception.

io.grpc.StatusRuntimeException: PERMISSION_DENIED: Dialogflow API has not been used in project project-number before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/dialogflow.googleapis.com/overview?project=project-number then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.

Relevant code snippet:

AgentsSettings agentsSettings = AgentsSettings.newBuilder().build();

AgentsClient client = AgentsClient.create(agentsSettings)
LocationName parent = LocationName.of("my project id", "US-CENTRAL1");
AgentsClient.ListAgentsPagedResponse agents = client.listAgents(parent);

Any help appreciated.



Solution 1:[1]

This error may indicate that the GOOGLE_APPLICATION_CREDENTIALS and/or GOOGLE_CLOUD_PROJECT environment variables were not properly set. Reviewing the Dialogflow CX Setup documentation may help.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Svetlana