I'm working on Node.js 14.15.1 on Win 10, using Dialogflow client library @google-cloud/dialogflow 3.3.0.
I try to create programmatically an agent, this is my code:
const dialogflow = require('@google-cloud/dialogflow');
const projectId = 'project name';
const agentClient = new dialogflow.AgentsClient({
keyFilename: "/path/to credentials.json file/"
});
if (agentClient){
console.log('ok');
}
var agentNuovo={
"parent": "projects/testxx",
"displayName": "xxxxx",
"defaultLanguageCode": "it",
"supportedLanguageCodes": [],
"timeZone": "Europe/Madrid",
"description": "abla bla bla",
"avatarUri": "",
"enableLogging": true,
"matchMode": "MATCH_MODE_UNSPECIFIED",
"classificationThreshold": 0.3,
"apiVersion": "API_VERSION_V2",
"tier": "TIER_STANDARD"
};
agentClient.setAgent({agent:agentNuovo}).then(responses => {
var response = responses[0];
//console.log(responses[0]);
console.log('response '+responses[0]);
}).catch(err => {
console.error(err);
});
I have given Dialogflow API admin/reader/client/integration manager role to the service account. Added also project owner but no way.
This is the stack error
Error: 7 PERMISSION_DENIED: IAM permission 'dialogflow.agents.create' on 'projects/testsetagente' denied.
at Object.callErrorFromStatus (
code: 7,
details: "IAM permission 'dialogflow.agents.create' on 'projects/testsetagente' denied.",
metadata: Metadata {
internalRepr: Map(1) { 'grpc-server-stats-bin' => [Array] },
options: {}
},
note: 'Exception occurred in retry method that was not classified as transient'
}
EDIT: I used "try this API" and the setAgent operation went ok.
Any ideas would be appreciated.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…