Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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"
  }
}
like image 1000
stkvtflw Avatar asked Jun 01 '18 06:06

stkvtflw


1 Answers

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.

like image 153
abtExp Avatar answered Jan 04 '23 04:01

abtExp