php - Actions-On-Google/Dialogflow:在 agentId 的平台响应中找不到 RichResponse 或 SystemIntent
问题描述
我正在使用 Dialogflow 和一个用 PHP 编写的 webhook 编写代理程序。最近我重新构建了部分代码,现在我总是在“Actions-on-Google-console”中遇到同样的错误:
由于平台响应无效,无法将 Dialogflow 响应解析为 AppResponse。在 agentId 的平台响应中找不到 RichResponse 或 SystemIntent
现在这是我的 webhook 中的部分代码:
if($action == "willkommen")
{
$google->Speak("Hallo Welt");
}
$google是我创建的包装器 PHP 类的对象。Speak()方法的代码如下所示:
public function Speak($text,$endConversation=false)
{
if($endConversation)
$expectUserResponse = false;
else
$expectUserResponse = true;
$toGoogle["payload"]["google"]["expectUserResponse"] = $expectUserResponse;
$toGoogle["payload"]["google"]["richResponse"]["items"][0]["simpleResponse"]["textToSpeech"] = $text;
file_put_contents("test.log",json_encode($toGoogle,JSON_PRETTY_PRINT));
echo json_encode($toGoogle,JSON_PRETTY_PRINT);
}
出于调试目的,我将生成的 JSON 写入文件test.log。它包含
{
"payload": {
"google": {
"expectUserResponse": true,
"richResponse": {
"items": [
{
"simpleResponse": {
"textToSpeech": "Hallo Welt"
}
}
]
}
}
}
}
所有代码都是从头到尾执行的,因为一旦我编辑了传递给Speak()的字符串, 我就可以看到 JSON 字符串的更改写入test.log。但是我不断收到上面的错误消息。我的 JSON 字符串有什么问题?谷歌怎么会找不到RichResponse?
非常感谢!任何帮助表示赞赏!
解决方案
请检查您的后备意图。
当回退意图未添加到代理时,“Actions-on-Google-console”会出现此错误。
推荐阅读
- binding - 将 SwiftUI 视图绑定到领域对象的意外行为
- python - 有没有办法在 Python 中进行 raking?
- php - 在图片下方显示产品简短描述
- iframe - 添加框架祖先/没有错误/但仍然无法显示 iframe
- c++ - 在堆栈上创建类实例
- javascript - 使用 jQuery 更改单击按钮的外观,并覆盖 btn-warning 类
- java - 如果未播放媒体播放器,应用程序退出时应用程序崩溃
- python - 如何在哈里斯角检测算法中实现计数器?
- tensorflow - 如何将数据提供给正在连接的 NN 模型?
- c - C 强制从另一个模块重新定义函数(monkeypatching)