Skip to content Skip to sidebar Skip to footer

Google Cloud Dialogflow Intent Detection Nodejs Example Not Working

I am trying to implement a very simple dialogflow agent integration with nodejs. Here is what I did so far I followed the code from Intent detection I added the service account pr

Solution 1:

i also faced a similar issue for my angular bot.

What i did was, instead of using using the google_credentials from the json file, i created an object with private_key,client_email {these values can be taken from the service account private key file .json}, and passed the object while setting up the session client.

var config = {
  credentials: {
    private_key: "YOUR_PRIVATE_KEY",
    client_email: "YOUR_CLIENT_EMAIL"
  }
}

const sessionClient = new dialogflow.SessionsClient(config);

note: do copy the full private_key string from .json. It will start as "-----BEGIN PRIVATE KEY-----\n......" .

Also, in GCP go to the project->IAM then try setting role for the service as DIALOGLOW API ADMIN. Check if this works.

Solution 2:

If this has not been resolved yet , the solution is to provide "fileKey" inside sessionClient.

const sessionClient = new dialogflow.SessionsClient({
fileKey:" path of your credentials.json file"
});

or

let filePath = process.env.GOOGLE_APPLICATION_CREDENTIALS ="Location of credentials file".

const sessionClient = new dialogflow.SessionsClient({
fileKey:filePath
});

this will even work if there is no system env variable is set as GOOGLE_APPLICATION_CREDENTIALS.

Hope this is helpful.

Post a Comment for "Google Cloud Dialogflow Intent Detection Nodejs Example Not Working"