TypeError: agent.intent is not a function at exports.dialogflowFirebaseFulfillment.functions.https.onRequest
TypeError: agent.intent is not a function at exports.dialogflowFirebaseFulfillment.functions.https.onRequest
我正在尝试使用 actions-on-google 轮播来显示少数项目,以处理我需要使用 intent('actions.intent.OPTION', (?,?,?)) 的点击操作功能,但这样做会导致以下错误,
ERROR:
TypeError: agent.intent is not a function at exports.dialogflowFirebaseFulfillment.functions.https.onRequest
密码是
const functions = require('firebase-functions');
const {
WebhookClient
} = require('dialogflow-fulfillment');
const {
Image,
Carousel,
BrowseCarousel,
BrowseCarouselItem,
} = require('actions-on-google');
exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {
const agent = new WebhookClient({
request,
response
});
agent.requestSource = agent.ACTIONS_ON_GOOGLE;
console.log('Dialogflow Request headers: ' + JSON.stringify(request.headers));
console.log('Dialogflow Request body: ' + JSON.stringify(request.body));
// Run the proper function handler based on the matched Dialogflow intent name
let intentMap = new Map();
intentMap.set('Welcome Intent', welcome);
intentMap.set('Default Fallback Intent', fallback);
intentMap.set('video.search', searchQuery);
// intentMap.set('your intent name here', googleAssistantHandler);
agent.handleRequest(intentMap);
agent.action('actions.intent.OPTION', (conv, params, option) => {
let response = 'You did not select any item';
if (option) {
response = 'You have chosen: ' + option;
}
conv.ask(response);
});
}
如果我遗漏了什么,请帮忙?
此外,我需要从意图处理方法触发深层 link,有什么方法可以从这里触发显式深层 link 意图 URI?
错误消息看起来很奇怪,但看起来您从 Google 的文档中复制了代码而没有阅读其余信息,并尝试将其更改为 agent.action
。
问题是您将 agent.action
视为函数 - 而事实并非如此。 This is a property 包含在 Intent 的参数部分中设置的 "action" 的名称。
通过 Dialogflow 处理 actions.intent.OPTION
是通过创建一个具有 事件 actions_intent_OPTION
且没有训练短语的 Intent。像这样:
然后您将拥有一个处理 "input.option" 意图的处理程序(使用我在示例中使用的名称),就像处理其他意图处理程序一样。
我正在尝试使用 actions-on-google 轮播来显示少数项目,以处理我需要使用 intent('actions.intent.OPTION', (?,?,?)) 的点击操作功能,但这样做会导致以下错误,
ERROR:
TypeError: agent.intent is not a function at exports.dialogflowFirebaseFulfillment.functions.https.onRequest
密码是
const functions = require('firebase-functions');
const {
WebhookClient
} = require('dialogflow-fulfillment');
const {
Image,
Carousel,
BrowseCarousel,
BrowseCarouselItem,
} = require('actions-on-google');
exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {
const agent = new WebhookClient({
request,
response
});
agent.requestSource = agent.ACTIONS_ON_GOOGLE;
console.log('Dialogflow Request headers: ' + JSON.stringify(request.headers));
console.log('Dialogflow Request body: ' + JSON.stringify(request.body));
// Run the proper function handler based on the matched Dialogflow intent name
let intentMap = new Map();
intentMap.set('Welcome Intent', welcome);
intentMap.set('Default Fallback Intent', fallback);
intentMap.set('video.search', searchQuery);
// intentMap.set('your intent name here', googleAssistantHandler);
agent.handleRequest(intentMap);
agent.action('actions.intent.OPTION', (conv, params, option) => {
let response = 'You did not select any item';
if (option) {
response = 'You have chosen: ' + option;
}
conv.ask(response);
});
}
如果我遗漏了什么,请帮忙?
此外,我需要从意图处理方法触发深层 link,有什么方法可以从这里触发显式深层 link 意图 URI?
错误消息看起来很奇怪,但看起来您从 Google 的文档中复制了代码而没有阅读其余信息,并尝试将其更改为 agent.action
。
问题是您将 agent.action
视为函数 - 而事实并非如此。 This is a property 包含在 Intent 的参数部分中设置的 "action" 的名称。
通过 Dialogflow 处理 actions.intent.OPTION
是通过创建一个具有 事件 actions_intent_OPTION
且没有训练短语的 Intent。像这样:
然后您将拥有一个处理 "input.option" 意图的处理程序(使用我在示例中使用的名称),就像处理其他意图处理程序一样。