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",}