【问题标题】:Google Home dialogFlow V2 API mediaResponse not workingGoogle Home dialogFlow V2 API mediaResponse 不起作用
【发布时间】:2018-03-22 16:34:02
【问题描述】:

我决定升级我的 Google Assistant 操作以使用“dialogFlow V2 API”,我的 webhook 返回一个像这样的对象

{
    "fulfillmentText": "Testing",
    "fulfillmentMessages": [
        {
            "text": {
                "text": [
                    "fulfillmentMessages text attribute"
                ]
            }
        }
    ],
    "payload": {
        "google": {
            "richResponse": {
                "items": [
                    {
                        "mediaResponse": {
                            "mediaType": "AUDIO",
                            "mediaObjects": [
                                {
                                    "name": "mediaResponse name",
                                    "description": "mediaResponse description",
                                    "largeImage": {
                                        "url": "https://.../640x480.jpg"
                                    },
                                    "contentUrl": "https://.../20183832714.mp3"
                                }
                            ]
                        },
                        "simpleResponse": {
                            "textToSpeech": "simpleResponse: testing",
                            "ssml": "simpleResponse: ssml",
                            "displayText": "simpleResponse displayText"
                        }
                    }
                ]
            }
        }
    },
    "source": "webhook-play-sample"
}

但我收到一条错误消息,说我的操作不可用,V2 是否支持 mediaResponse?,我应该以不同的方式格式化我的对象吗?另外,当我删除“mediaResponse”对象时工作正常,助手会说话simpleResponse 部分。

这个动作是在 2018 年 3 月中旬重新创建的,我读到了 5 月的截止日期,这就是为什么我决定升级到 V2,你认为我应该回到 V1,我知道我必须删除它并重新-created 但没关系。这是我在调试选项卡中看到的JSON 对象的链接。再次感谢

我在操作 dialogFlow 控制台中设置了“API V2”,这是该设置的screenshot

这是我的操作集成的screenshoot -> Google 助理

谢谢艾伦,是的,我确实有 "expectUserResponse": false,我添加了您推荐的建议对象,但不幸的是,没有任何改变,我仍然收到此错误 Simulator debug tag details

【问题讨论】:

  • 您在谈论哪个“V2””Google V2 或 Dialogflow V2 上的操作?(您在哪里更改设置以使用 V2?)
  • 好的,您可以转到“集成”页面并选择“Google 助理”并附上屏幕截图吗?

标签: actions-on-google dialogflow-es google-home


【解决方案1】:

首先 - 这不是 Dialogflow V2 的问题。您似乎也将 Actions on Google V1 的日落与 Dialogflow V2 的发布混淆了——它们完全是两种不同的生物。如果您的项目使用的是 AoG V1,则 Actions 集成屏幕上会有一个设置,而您没有。

如果您想迁移到 Dialogflow V2 也可以,但这不是必需的。媒体绝对可以在 Dialogflow V2 下运行。

items 的数组必须首先包含 simpleResponse 项,然后是 RichResponse 中的任何其他项。 (您也不应该同时包含 ssmltextToSpeech - 只是其中之一。)您也不需要 fulfillmentTextfulfillmentMessages 组件,因为它们是由 richResponse 提供的。

除非您将expectUserResponse 设置为false,否则您还需要包含建议筹码。模拟器调试中的某个地方可能是一个块,上面写着

      {
        "name": "MalformedResponse",
        "debugInfo": "expected_inputs[0].input_prompt.rich_initial_prompt: Suggestions must be provided if media_response is used..",
        "subDebugEntryList": []
      }

所以更像这样的东西应该可以工作:

{
    "payload": {
        "google": {
            "richResponse": {
                "items": [
                    {
                        "simpleResponse": {
                            "textToSpeech": "simpleResponse: testing",
                            "displayText": "simpleResponse displayText"
                        },
                        "mediaResponse": {
                            "mediaType": "AUDIO",
                            "mediaObjects": [
                                {
                                    "name": "mediaResponse name",
                                    "description": "mediaResponse description",
                                    "largeImage": {
                                        "url": "https://.../640x480.jpg"
                                    },
                                    "contentUrl": "https://.../20183832714.mp3"
                                }
                            ]
                        }
                    }
                ]
                "suggestions": [
                    {
                        "title": "This"
                    },
                    {
                        "title": "That"
                    }
                ]
            }
        }
    },
    "source": "webhook-play-sample"
}

【讨论】:

  • 谢谢艾伦,但这并没有解决问题,我仍然收到“{myActionName} 现在没有响应,稍后再试”;(
  • 你在用模拟器测试这个吗?您能否更新问题以包括模拟器的屏幕截图,显示错误并显示“调试”选项卡?
  • 不要过多解读,因为内部表示不一定与我们看到的 API 名称相同。您正在使用的 Dialogflow 项目有多长时间了?你是在去年五月之前创建的吗? (并且显示模拟器的整个屏幕会有所帮助 - 只是那个片段并没有太大帮助。)
  • 更新原始问题比尝试在 cmets 中提供链接和更新要好。
  • 更新了答案。 (两部分,一部分是关于 V1 与 V2,另一部分是关于 JSON 中缺少的一些内容。)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-03-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-05-27
  • 2019-01-27
相关资源
最近更新 更多