gpt4 book ai didi

actions-on-google - Dialogflow函数: Cannot read property 'client' of undefined

转载 作者:行者123 更新时间:2023-12-04 13:56:42 27 4
gpt4 key购买 nike

我终于让用户注册了此云功能:

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)

但是在那之后我又遇到了同样的错误:
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)

它甚至没有到达 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"
}
}

最佳答案

在初始化您的应用程序时

const app = dialogflow();

传递一个对象,将您对Google帐户的操作关联到客户端ID

您的代码应如下所示:
const app = dialogflow({
clientId : YOUR_APPS_CLIENT_ID
})

这将解决此问题。

要获取YOUR_APPS_CLIENT_ID,请转到Google控制台上的操作,在左侧导航菜单的高级选项下,转到帐户关联并展开第三张卡以获取您的ID。

希望能帮助到你。

关于actions-on-google - Dialogflow函数: Cannot read property 'client' of undefined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50637650/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com