1

我有一个来自我的谷歌助手新操作构建器平台的网络钩子。Webhook 代码是用 dotnet vs2019 编写的。我遵循了以下链接中提供的 webhook 请求和响应格式以及示例 json。

https://developers.google.com/assistant/conversational/reference/rest/v1/TopLevel/fulfill#User

https://developers.google.com/assistant/conversational/webhooks#request-json_1

但是当我测试助手动作时,它失败了。下面是来自谷歌助手测试模拟器日志的请求和响应 json。错误消息只是说“来自 webhook 的无效响应:无法将 JSON 转换为 ExecuteHttpResponse。” 我不知道为什么它无效。有人可以帮我解决这个问题。

{
  "requestJson": {
    "handler": {
      "name": "agentcube"
    },
    "intent": {
      "name": "",
      "params": {
        "phone": {
          "original": "1234562869",
          "resolved": 1234562869
        }
      },
      "query": "1234562869"
    },
    "scene": {
      "name": "Start",
      "slotFillingStatus": "FINAL",
      "slots": {
        "Zip": {
          "mode": "REQUIRED",
          "status": "SLOT_UNSPECIFIED",
          "updated": false,
          "value": 37122
        },
        "Phone": {
          "mode": "REQUIRED",
          "status": "SLOT_UNSPECIFIED",
          "updated": true,
          "value": 1234562869
        },
        "FName": {
          "mode": "REQUIRED",
          "status": "SLOT_UNSPECIFIED",
          "updated": false,
          "value": "john doe"
        }
      },
      "next": {
        "name": "actions.scene.END_CONVERSATION"
      }
    },
    "session": {
      "id": "ABwppHFkFuGBF-UawPmIkxWpkfM1Hb5An7h8KnjR302zukmBoKA1NqDp7DfePGzYsyxT5oy--wg5Jkjj",
      "params": {
        "Phone": 1234562869,
        "FName": "john doe",
        "Zip": 37122
      },
      "typeOverrides": [],
      "languageCode": ""
    },
    "user": {
      "locale": "en-US",
      "params": {},
      "accountLinkingStatus": "NOT_LINKED",
      "verificationStatus": "VERIFIED",
      "packageEntitlements": [],
      "gaiamint": "",
      "permissions": [],
      "lastSeenTime": "2021-01-28T19:21:28Z"
    },
    "home": {
      "params": {}
    },
    "device": {
      "capabilities": [
        "SPEECH",
        "RICH_RESPONSE",
        "LONG_FORM_AUDIO"
      ]
    }
  }
}

  

来自 webhook 的无效响应:无法将 JSON 转换为 ExecuteHttpResponse..

{
  "responseJson": {
    "Session": {
      "Id": "ABwppHFkFuGBF-UawPmIkxWpkfM1Hb5An7h8KnjR302zukmBoKA1NqDp7DfePGzYsyxT5oy--wg5Jkjj",
      "Params": {
        "Phone": 1234562869,
        "Zip": 37122,
        "FName": "john doe"
      }
    },
    "Prompt": {
      "Override": false,
      "FirstSimple": {
        "Speech": "My webhook response",
        "Text": "My response from webhook"
      }
    },
    "Scene": {
      "Name": "Start",
      "SlotFillingStatus": "FINAL",
      "Slots": {
        "Phone": {
          "Mode": "REQUIRED",
          "Status": "SLOT_UNSPECIFIED",
          "Updated": true,
          "value": 1234562869
        },
        "FName": {
          "Mode": "REQUIRED",
          "Status": "SLOT_UNSPECIFIED",
          "Updated": false,
          "value": "john doe"
        },
        "Zip": {
          "Mode": "REQUIRED",
          "Status": "SLOT_UNSPECIFIED",
          "Updated": false,
          "value": 37122
        }
      },
      "Next": {
        "Name": "actions.scene.END_CONVERSATION"
      }
    }
  }
}
4

1 回答 1

0

通过检查 linter 确保您的代码返回的响应是 json,这似乎可以检查(即 ResponseJson {} 中的所有内容,请参阅我在https://stackoverflow.com/a/66512370上对类似问题的回复/10537202使用 webhook 游乐场。

于 2021-03-07T01:33:17.320 回答