I am trying to access Google's DialogFlow API using nodeJS and get the following error:
Error: Could not load the default credentials.
It finds the API key fine and loads the client, but wont run the query under localhost. It seems to be looking for the default credentials, but I am specifying ones from the service account.
const {SessionsClient} = require('@google-cloud/dialogflow').v2;
const dfKey=JSON.parse(fs.readFileSync("./assets/keys/dialogflow.json"));
const dfClient=new dialogflow.SessionsClient({ private_key:dfKey.private_key,client_email:dfKey.client_email });
const detectIntent = async (queryText, sessionId="123456789") => {
let sessionPath=dfClient.projectAgentSessionPath(dfKey.project_id, sessionId);
let request = { session: sessionPath, queryInput:{ text: { text: queryText, languageCode: "en" } } };
const responses = await dfClient.detectIntent(request);
console.log(responses);
const result = responses[0].queryResult;
console.log(result);
return { response: result.fulfillmentText };
}
detectIntent("How are you")
It finds the API key fine and loads the client, but wont run the query under localhost. It seems to be looking for the default credentials, but I am specifying ones from the service account.