对话框流程响应:Google上的操作

时间:2018-12-04 15:55:45

标签: dialogflow actions-on-google

嗨,我正在从DialogFlow发送具有丰富响应的响应。这个丰富的响应包含Carousel,但我只看到简单的响应。我在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": []
            }
        }
    }
}

1 个答案:

答案 0 :(得分:1)

如果直接将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's sample github repository。)