6

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"
  }
}
stkvtflw
  • 12,092
  • 26
  • 78
  • 155
  • What happens with the second code? – Prisoner Jun 01 '18 at 09:32
  • any code, that uses `dialogflow` from `actions-on-google`, throws the error `Cannot read property 'client' of undefined` – stkvtflw Jun 02 '18 at 05:12
  • Can you update your question to include the contents of your package.json? – Prisoner Jun 02 '18 at 09:33
  • @Prisoner it's done – stkvtflw Jun 02 '18 at 16:32
  • Is it throwing this error when you start the client, or when you try to do something? – Prisoner Jun 02 '18 at 19:13
  • it throwing this error when i'm calling for the intent, that is using this funciton – stkvtflw Jun 02 '18 at 19:49
  • Sorry, this is a wild guess. I was searching for "client" in the dialogflow.ts source code: https://github.com/actions-on-google/actions-on-google-nodejs/blob/master/src/service/dialogflow/dialogflow.ts#L416 was the only reference I could find. It seems to be talking about authentication. Not an answer - but something that might be related. – Alan Kent Jun 05 '18 at 06:57
  • I also encountered the same problem, ***not once but twice.*** The first time it was the problem with my CLIENT_ID. As I viewed it in Actions on Google Console in [Firefox](https://i.stack.imgur.com/L2DZN.png) the **CLIENT_ID** is partially visible and is non-selectable, thus I copied it partially (as I wasn't aware) and encountered the errors. After hours of searching and luckily trying AoG console on [Google Chrome](https://i.stack.imgur.com/HX3J5.png), I found that the **CLIENT_ID** part scrolls and has a certain length. The second time it happened as I saved my **CLIENT_ID** in another fil – Tarun Singh Jul 17 '19 at 21:52

3 Answers3

11

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.

Inzamam Malik
  • 3,238
  • 3
  • 29
  • 61
abtExp
  • 9
  • 1
  • 14
0

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

Jordi
  • 3,041
  • 5
  • 17
  • 36
adkl
  • 634
  • 7
  • 17
  • Google has updated their accountlinking settings again in October 2019. You can now also find the Client ID under the Google Sign-in details in your Google project. https://stackoverflow.com/a/58063700/6351280 – Jordi Oct 04 '19 at 14:30
0

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

Jordi
  • 3,041
  • 5
  • 17
  • 36