stkvtflw
stkvtflw

Reputation: 13507

Dialogflow functions: Cannot read property 'client' of undefined

I've finally got user signed up with this cloud function:

const functions = require('firebase-functions');
const {
  dialogflow,
  Image,
} = require('actions-on-google')

// Create an app instance

const app = dialogflow()

// Register handlers for Actions SDK intents

app.intent('test', conv => {
  conv.ask(new SignIn());
})

exports.dialogflowFirebaseFulfillment = functions.https.onRequest(app)

But right after that i'm getting the same error:

TypeError: Cannot read property 'client' of undefined
    at Function.<anonymous> (/user_code/node_modules/actions-on-google/dist/service/dialogflow/dialogflow.js:120:71)
    at next (native)
    at /user_code/node_modules/actions-on-google/dist/service/dialogflow/dialogflow.js:22:71
    at __awaiter (/user_code/node_modules/actions-on-google/dist/service/dialogflow/dialogflow.js:18:12)
    at Function.handler (/user_code/node_modules/actions-on-google/dist/service/dialogflow/dialogflow.js:84:16)
    at Object.<anonymous> (/user_code/node_modules/actions-on-google/dist/assistant.js:55:32)
    at next (native)
    at /user_code/node_modules/actions-on-google/dist/assistant.js:22:71
    at __awaiter (/user_code/node_modules/actions-on-google/dist/assistant.js:18:12)
    at standard (/user_code/node_modules/actions-on-google/dist/assistant.js:51:41)

It doesn't even get to the console.log('test'):

const functions = require('firebase-functions');
const {dialogflow} = require('actions-on-google')

// Create an app instance

const app = dialogflow()

// Register handlers for Actions SDK intents

app.intent('test', conv => {
  console.log('test')
  conv.ask(`response`)
})

exports.dialogflowFirebaseFulfillment = functions.https.onRequest(app)

Package.json:

{
  "name": "dialogflowFirebaseFulfillment",
  "description": "This is the default fulfillment for a Dialogflow agents using Cloud Functions for Firebase",
  "version": "0.0.1",
  "private": true,
  "license": "Apache Version 2.0",
  "author": "Google Inc.",
  "engines": {
    "node": "~6.0"
  },
  "scripts": {
    "start": "firebase serve --only functions:dialogflowFirebaseFulfillment",
    "deploy": "firebase deploy --only functions:dialogflowFirebaseFulfillment"
  },
  "dependencies": {
    "actions-on-google": "2.1.3",
    "firebase-admin": "5.12.1",
    "firebase-functions": "1.0.3",
    "dialogflow": "0.5.0",
    "dialogflow-fulfillment": "0.4.0"
  }
}

Upvotes: 6

Views: 2540

Answers (3)

abtExp
abtExp

Reputation: 15

goto your action on google app Develop section, goto account linking, expand Google Sign In Client Information you will see Client ID issued by Google to your Actions copy that client id.

when initializing your app in

const app = dialogflow();

pass in an object with your actions on google account linking client id

your code should look like:

const app = dialogflow({
   clientId : YOUR_APPS_CLIENT_ID
})

This will fix this issue.

To Get YOUR_APPS_CLIENT_ID, go to actions on google console, on the left nav menu, under advanced options, go to account linking and expand the third card to get your id.

Hope it helps.

Upvotes: 11

jacobytes
jacobytes

Reputation: 3241

I faced this issue when I didnt want to accountlink in a test project of mine, I had left accountlinking on from when I was testing something. When I connected a webhook without any clientID in the code I got the error. All I had to do was clear the accountlink settings from the Google project and then everything was solved.

enter image description here

Upvotes: 0

adkl
adkl

Reputation: 643

Update for September 2019

If you can't find your Client ID (as it was for me, because it seems Google doesn't show it anymore within the "Google Sign In Client Information" card), then go to your Google Cloud Platform console and under APIs and Services menu, open the Credentials screen.

Then scroll to the OAuth 2.0 client IDs section and find "New Actions on Google App". The value in the last column is your Client ID for Actions on Google project.

Here is the screenshot:

enter image description here

Upvotes: 0

Related Questions