-1

I am fetching my agent details from dialogflow using php client API

I have authenticated my agent on google clous sdk.Moreover,other methods work perfectly fine.

require 'vendor/autoload.php';
use Google\Cloud\Dialogflow\V2\AgentsClient;
use Google\Cloud\Dialogflow\V2\SessionsClient;
function get_agent($projectId,$sessionId,$project_name)
{
    $test = array('credentials' => 'client-secret.json');
    $sessionsClient = new SessionsClient($test);
    $session = $sessionsClient->sessionName($projectId, $sessionId ?: 
    uniqid());
    printf('Session path: %s' . PHP_EOL, $session);
    $agentsClient = new AgentsClient();
    try{
        $formattedParent = $agentsClient->projectName($project_name);
        $response = $agentsClient->getAgent($formattedParent);
    } 
    finally {
        $agentsClient->close();
    }
}
get_agent('xxxx-faqs-kcdeuh','1234','xxxx');

PHP Fatal error: Uncaught Google\ApiCore\ApiException: { "message": "IAM permission 'dialogflow.agents.get' on 'projects/xxxxx' denied.", "code": 7, "status": "PERMISSION_DENIED",}

1 Answers1

0

The error message is an IAM permission denied, which means that you are authenticated, but not authorized to perform a 'dialogflow.agents.get' action on the 'projects/xxxx' object.

To be able to overcome this impediment, an administrator of the resource (projects/xxxxxx) needs to grant the required permission (dialogflow.agents.get).

Here is an answer explaining the process: PermissionDenied: 403 IAM permission 'dialogflow.intents.list'

Oerd
  • 2,256
  • 1
  • 21
  • 35