【发布时间】:2018-01-18 16:41:05
【问题描述】:
我正在使用 Actions SDK,并且我有不同的配置来让模拟器调用我的自定义意图!似乎模拟器拒绝触发除 MAIN 之外的任何操作,甚至拒绝触发 TEXT。下面是我的 action.json:
{
"actions": [
{
"description": "Default Welcome Intent",
"name": "MAIN",
"fulfillment": {
"conversationName": "SHOPPING"
},
"intent": {
"name": "actions.intent.MAIN",
"trigger": {
"queryPatterns": [
"Talk to stroller shopping expert"
]
}
}
},
{
"description": "Listing strollers for a specified age group",
"name": "SHOPPING",
"fulfillment": {
"conversationName": "SHOPPING"
},
"intent": {
"name": "SHOPPING",
"trigger": {
"queryPatterns": [
"I am looking for a jogging stroller",
"I am shopping for a jogging stroller"
]
}
}
}
],
"conversations": {
"SHOPPING": {
"name": "SHOPPING",
"url": "SOME_URL (I have a valid URL BTW)",
"fulfillmentApiVersion": 2
}
}
}
我正在使用 firebase,但在 firebase 日志中,我看不到任何来自我的自定义或 TEXT 意图的日志。以下是我的 index.json 代码的一部分:
'use strict';
process.env.DEBUG = 'actions-on-google:*';
const ActionsSdkApp = require('actions-on-google').ActionsSdkApp;
const functions = require('firebase-functions');
const NO_INPUTS = [
'Padon me, I didn\'t hear that.',
'If you\'re still there, would you please say that again.',
'We can stop here. Good luck with your shopping.'
];
const SHOPPING_INTENT = 'SHOPPING';
exports.shopStrollers = functions.https.onRequest((request, response) => {
const app = new ActionsSdkApp({request, response});
function handleMainInput(app) {
console.log('mainIntent is invoked!');
console.log("The input is %s", app.getRawInput());
console.log("It seems that %s is never invoked!", app.StandardIntents.TEXT)
let inputPrompt = app.buildInputPrompt(true, '<speak>Hi! <break time="1"/> ' +
'I can help with finding strollers. How old is your baby?</speak>', NO_INPUTS);
app.ask(inputPrompt);
}
function handleTextInput(app) {
console.log('TEXT is invoked!');
console.log("The input is %s", app.getRawInput());
console.log("Finally TEXT HANDLER got invoked")
if (app.getRawInput() === 'bye') {
app.tell('Hope you found the service helpful and best of luck with your shopping, please come back again, goodbye!');
} else {
let inputPrompt = app.buildInputPrompt(true, '<speak>Here is a list of top' +
' <say-as interpret-as="ordinal">10</say-as>strollers' +
', say next for the next batch</speak>', NO_INPUTS);
app.ask(inputPrompt);
}
}
let actionMap = new Map();
actionMap.set(SHOPPING_INTENT, handleTextInput);
actionMap.set(app.StandardIntents.MAIN, handleMainInput);
actionMap.set(app.StandardIntents.TEXT, handleTextInput);
app.handleRequest(actionMap);
});
有人知道可能出了什么问题,我将不胜感激。
【问题讨论】:
-
你的 NLU 工作正常吗?
-
如果你看index.js中的handleTextInput函数,我只是想记录一些东西并提示一个消息。还没有进一步的 NLU 功能!一旦我越过了这个障碍,我就会把它连接到我的 NLU 组件上。
-
请随意忽略我——这条评论带有主观色彩。但是 IMO 易于调试是我喜欢在没有 Firebase 的情况下开始这些事情的原因之一。如果您知道如何构建 Node 和 Express 服务器,并且如果您将 ngrok 作为反向代理/隧道安装到您的开发机器,那么您可以使用 ngrok 的内置日志记录来查看您和 AoG 之间的线路上有什么和没有什么相当容易地诊断问题。如果您小心,您只需几行代码即可在非 Firebase 和 Firebase 版本之间共享代码。
-
我想我将不得不这样做,我希望避免它。我稍后会分享结果。
-
@WilliamDePalo 我创建了一个简单的快速应用程序并创建了一个模拟响应。模拟器通过 ngrok 调用我的本地 express 应用程序,但后续请求从未发送到我的应用程序。我对firebase应用程序有同样的问题。因此,看来问题不在于 Firebase 或我的本地应用程序。我在 action.json 中遗漏了一些东西,我无法弄清楚它是什么?!我需要为每个意图创建一个新对话吗?
标签: chatbot actions-on-google google-home google-assistant-sdk