简体   繁体   中英

Actions-On-Google/Dialogflow: Could not find a RichResponse or SystemIntent in the platform response for agentId

I am coding an agent with Dialogflow and a webhook written in PHP. Lately I re-structured parts of my code and now I always get the same error in the "Actions-on-Google-console":

Failed to parse Dialogflow response into AppResponse because of invalid platform response. Could not find a RichResponse or SystemIntent in the platform response for agentId

Now here is part of the code from my webhook:

if($action == "willkommen")
{
   $google->Speak("Hallo Welt");
}

$google is an object of a wrapper-PHP-class I created. The code of the method Speak() looks like 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);
}

For debugging purpose I write the generated JSON to the file test.log . It contains

{
    "payload": {
        "google": {
            "expectUserResponse": true,
            "richResponse": {
                "items": [
                    {
                        "simpleResponse": {
                            "textToSpeech": "Hallo Welt"
                        }
                    }
                ]
            }
        }
    }
}

All the code is executed from start to finish becaue once I edit the string passed over to Speak() then I can see a change of the JSON-string wirtten to test.log . However I keep getting the error message above. What is wrong with my JSON-string? How can it be Google fails to find the RichResponse ?

Thanks a lot! Any help is appreciated!

Please check your Fallback Intent.

"Actions-on-Google-console" gives this error when fallback intent is not added to the agent.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM