Getting TypeError: conv.parameters in not a function at app.intent with Dialogflow fufillment
Getting TypeError: conv.parameters in not a function at app.intent with Dialogflow fufillment
我正在尝试了解有关 Dialogflow fulfillment 的更多信息,我正在关注 youtube 上的教程 here。
当我部署和测试时,我在聊天机器人中得到了一个空响应。我可以看到以下错误:
TypeError:conv.parameters 不是 app.intent 处的函数 (/srv/index.js:24:23)
有人能帮我们找出我哪里出错了吗?代码如下:
const functions = require('firebase-functions')
const {dialogflow}=require('actions-on-google')
const WELCOME_INTENT = 'Default Welcome Intent'
const FALLBACK_INTENT = 'Default Fallback Intent'
const Dept_ENTITY= 'DEPTChoice'
const Dept_INTENT='DEPT'
const app = dialogflow()
app.intent(WELCOME_INTENT, (conv) => {
conv.ask("Hi! I am a test bot - what department are you in?")
})
app.intent(FALLBACK_INTENT, (conv) => {
conv.ask("huh?")
})
app.intent(DEPT_INTENT, (conv) => {
const dept_type=conv.parameters('DEPTChoice').toLowerCase()
if (dept_type == "Sales") {
conv.ask("Great Sales")
} else conv.ask("Great - Your in Sales")
})
exports.dialogflowFirebaseFulfillment = functions.https.onRequest(app)
正如错误信息所说,conv.parameters
不是一个函数。
它是一个JavaScript对象,其中对象属性是参数的名称。所以你的行可以写成
const dept_type = conv.parameters['DEPTChoice'].toLowerCase();
请注意使用方括号 []
来引用对象上的 属性,而不是使用圆括号 ()
来进行函数调用。这可能是视频中很难看到的。
我正在尝试了解有关 Dialogflow fulfillment 的更多信息,我正在关注 youtube 上的教程 here。
当我部署和测试时,我在聊天机器人中得到了一个空响应。我可以看到以下错误: TypeError:conv.parameters 不是 app.intent 处的函数 (/srv/index.js:24:23)
有人能帮我们找出我哪里出错了吗?代码如下:
const functions = require('firebase-functions')
const {dialogflow}=require('actions-on-google')
const WELCOME_INTENT = 'Default Welcome Intent'
const FALLBACK_INTENT = 'Default Fallback Intent'
const Dept_ENTITY= 'DEPTChoice'
const Dept_INTENT='DEPT'
const app = dialogflow()
app.intent(WELCOME_INTENT, (conv) => {
conv.ask("Hi! I am a test bot - what department are you in?")
})
app.intent(FALLBACK_INTENT, (conv) => {
conv.ask("huh?")
})
app.intent(DEPT_INTENT, (conv) => {
const dept_type=conv.parameters('DEPTChoice').toLowerCase()
if (dept_type == "Sales") {
conv.ask("Great Sales")
} else conv.ask("Great - Your in Sales")
})
exports.dialogflowFirebaseFulfillment = functions.https.onRequest(app)
正如错误信息所说,conv.parameters
不是一个函数。
它是一个JavaScript对象,其中对象属性是参数的名称。所以你的行可以写成
const dept_type = conv.parameters['DEPTChoice'].toLowerCase();
请注意使用方括号 []
来引用对象上的 属性,而不是使用圆括号 ()
来进行函数调用。这可能是视频中很难看到的。