首页 > 解决方案 > 对话流响应:Google 上的操作

问题描述

嗨,我正在从 DialogFlow 发送具有丰富响应的响应。这个丰富的响应包含轮播,但我只看到简单的响应。我在 GA 中没有看到轮播响应。我的响应有任何缺陷吗?我在控制台上的操作模拟器中没有看到任何错误..

"payload": {
        "google": {
            "expectUserResponse": true,
            "richResponse": {
                "items": [
                    {
                        "simpleResponse": {
                            "textToSpeech": "Please follow these steps:",
                            "displayText": "Please follow these steps:"
                        },
                        "Carousel": {
                            "items": [
                                {
                                    "title": "Step 1/6",
                                    "description": "hello",
                                    "image": {
                                        "url": "https://www.xx",
                                        "accessibilityText": "hello"
                                    }
                                },
                                {
                                    "title": "Step 2/6",
                                    "description": "hello",
                                    "image": {
                                        "url": "https://www.xx",
                                        "accessibilityText": "hello"
                                    }
                                },

                            ]
                        }
                    }
                ],
                "suggestions": []
            }
        }
    }
}

标签: dialogflow-esactions-on-google

解决方案


如果您直接发回 JSON,则 Carousel 和 List 对象不属于该richResponse属性。相反,它们是在systemIntent属性的子项中指定的。

整个响应可能看起来像这样

{
  "payload": {
    "google": {
      "expectUserResponse": true,
      "richResponse": {
        "items": [
          {
            "simpleResponse": {
              "textToSpeech": "Choose a item"
            }
          }
        ]
      },
      "systemIntent": {
        "intent": "actions.intent.OPTION",
        "data": {
          "@type": "type.googleapis.com/google.actions.v2.OptionValueSpec",
          "carouselSelect": {
            "items": [
              {
                "optionInfo": {
                  "key": "first title"
                },
                "description": "first description",
                "image": {
                  "url": "https://developers.google.com/actions/images/badges/XPM_BADGING_GoogleAssistant_VER.png",
                  "accessibilityText": "first alt"
                },
                "title": "first title"
              },
              {
                "optionInfo": {
                  "key": "second"
                },
                "description": "second description",
                "image": {
                  "url": "https://lh3.googleusercontent.com/Nu3a6F80WfixUqf_ec_vgXy_c0-0r4VLJRXjVFF_X_CIilEu8B9fT35qyTEj_PEsKw",
                  "accessibilityText": "second alt"
                },
                "title": "second title"
              }
            ]
          }
        }
      }
    }
  }
}

(取自Dialogflow 的示例 github 存储库。)


推荐阅读