本文介绍了什么是“未能将Dialogflow响应解析为AppResponse".在Google行动中的意思是的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用一个简单的webhook(用PHP编写)来与Google上的dialogflow/actions协同工作.我有一个对话框流程意图标签为"hello",该意图链接到"Google Assistant Welcome"和对话框流程"welcome"事件.

I am trying to get a simple webhook (written in PHP) to work with dialogflow/actions on google. I have a dialog flow intent labled "hello" which is linked to the "google assistant welcome" and dialog flow "welcome" events.

设置为启用Webhook,并且在对话框流测试区域中一切正常.但是,当我在Google Assistant中对其进行测试时,出现以下错误:

it is set to enable webhook, and everything works correctly in the dialog flow test area. when i test it in google assistant, however, i get the following error:

格式错误的响应无法将Dialogflow响应解析为AppResponse."

"MalformedResponseFailed to parse Dialogflow response into AppResponse."

我不知道出什么问题了.这是我的JSON响应的样子:

I have no clue what is wrong. Here is what my JSON response looks like:

{
  "payload": {
    "google": {
      "expectUserResponse": false,
      "richResponse": {
        "items": {
          "simpleResponse": {
            "textToSpeech": "test speech"
          }
        }
      }
    }
  },
  "fulfillmentText": "fulfillment test"
}

谢谢!

推荐答案

它在Dialogflow测试区域中起作用,因为它仅测试响应的Dialogflow部分.它会忽略特定于平台的payload区域下的任何内容.

It works in the Dialogflow test area because that just tests the Dialogflow portion of the response. It ignores anything under the platform-specific payload area.

您的有效载荷包含一个小错误. richResponse items属性.应该是项目对象的数组,即使您只发送一个.

Your payload contains a small error. The items property of the richResponse should be an array of item objects, even if you're only sending one.

因此JSON的该部分应类似于:

So that part of your JSON should look more like:

  "richResponse": {
    "items": [
      {
        "simpleResponse": {
          "textToSpeech": "test speech"
        }
      }
    ]
  }

这篇关于什么是“未能将Dialogflow响应解析为AppResponse".在Google行动中的意思是的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 09:49