How to get credentialsFile for Dialogflow NLU integration

dialogflow

#1

I’m trying to set up the Dialogflow NLU integration (importing DialogflowNlu from package jovo-nlu-dialogflow) for the web platform.

I’m stuck trying to figure out what to use as the credentialsFile property.

The code goes like this:

const { DialogflowNlu } = require('jovo-nlu-dialogflow')
//... stuff
app.use(
	new WebPlatform().use(
		new DialogflowNlu({
			credentialsFile: 'credentials.json'
		})
	),
	new Alexa(),
	new GoogleAssistant(),
	new JovoDebugger(),
	new FileDb()
)

Now, I’ve read somewhere in the Slack channels that credentials.json is supposed to be inside the src folder and that the credentialsFile property is the relative path to it.

What I have not found anywhere is an explanation or sample of what this file is supposed to look like, or instructions on where to get it from.

I found some help over Slack and was directed to these docs:
https://cloud.google.com/dialogflow/es/docs/quick/setup

I’ve made it to this console

I tried using the Oauth2 client ID’s file downloaded from there, but ran into this error.

  Error -----------------------------------------------------------------
  
  Message:
  No key or keyFile set.
  
  Stack:
  Error: No key or keyFile set.
      at GoogleToken.getTokenAsync (/Users/me/ws/my-project/node_modules/gtoken/build/src/index.js:125:19)
      at GoogleToken.getToken (/Users/me/ws/my-project/node_modules/gtoken/build/src/index.js:77:21)

To be clear, this is what this file looks like

{
	"web": {
		"client_id": "562***.apps.googleusercontent.com",
		"project_id": "myproject",
		"auth_uri": "https://accounts.google.com/o/oauth2/auth",
		"token_uri": "https://oauth2.googleapis.com/token",
		"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
		"client_secret": "0lA***",
		"redirect_uris": [
			"https://myproject.firebaseapp.com/__/auth/handler"
		],
		"javascript_origins": [
			"http://localhost",
			"http://localhost:5000",
			"https://myproject.firebaseapp.com"
		]
	}
}

I don’t think this is the right file to use. If anyone has a sample they can mask and share, and instructions on where to get the file from, that would be great.


#2

Hi @Miguelangel_Fernande,

This tutorial is a bit outdated, but it shows the steps necessary to create a service account and download its credentials file: https://www.jovo.tech/tutorials/deploy-dialogflow-agent


#3

Thank you, @jan . This was very useful :slight_smile: