我正在用对话框和用PHP编写的webhook编写一个代理代码。最近,我重新构造了代码的部分,现在我总是在“在Google-控制台上的操作”中遇到同样的错误:
由于平台响应无效,
未能将对话框流响应解析为AppResponse。无法在平台响应RichResponse或SystemIntent中找到agentId
下面是我的web钩子代码的一部分:
if($action == "willkommen")
{
$google->Speak("Hallo Welt");
}$google是我创建的一个包装器-PHP类的对象。方法this()的代码如下所示:
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"
}
}
]
}
}
}
}所有的代码都是从头到尾执行的,因为一旦我编辑了传递给start ()的字符串,我就可以看到JSON-string转换为test.log。不过,我一直收到上面的错误消息。我的JSON字符串怎么了?为什么谷歌找不到RichResponse
非常感谢!任何帮助都是非常感谢的!
发布于 2020-02-11 06:38:33
请检查你的撤退意图。
“Actions-on console”在不向代理添加回退意图时会出现此错误。
https://stackoverflow.com/questions/58504605
复制相似问题