【问题标题】:Dialogflow v2 API - cards not shown in the simulatorDialogflow v2 API - 模拟器中未显示的卡片
【发布时间】:2023-03-23 08:47:01
【问题描述】:

我有一个用于实现的 webhook。 下面是响应的代码

  let result_obj = {
    "fulfillmentText": "This is a text response",
    "fulfillmentMessages": [
      {
        "text": {
          "text": [
            "this is test"
          ]
        }
      },
      {
        "card": {
          "title": "card title",
          "subtitle": "card text",
          "imageUri": "https://assistant.google.com/static/images/molecule/Molecule-Formation-stop.png",
          "buttons": [
            {
              "text": "button text",
              "postback": "https://assistant.google.com/"
            }
          ]
        }
      }
    ]
}

以下是对话流 GUI 的结果

以下是我从模拟器或 Android 手机上的 Google Assistant 应用程序运行时得到的结果

模拟器和手机都没有显示卡片。我在这里遗漏了一些明显的东西吗?

【问题讨论】:

    标签: dialogflow-es google-home google-assist-api


    【解决方案1】:

    要在 Google 助理上显示卡片等丰富的响应,您必须使用响应 JSON 的 payload 部分,下面是一个示例:

    {
        "fulfillmentText": "This is a text response",
        "fulfillmentMessages": [],
        "source": "example.com",
        "payload": {
            "google": {
                "expectUserResponse": true,
                "richResponse": {
                    "items": [
                        {
                            "simpleResponse": {
                                "textToSpeech": "This is a Basic Card:"
                            }
                        },
                        {
                            "basicCard": {
                                "title": "card title",
                                "image": {
                                    "url": "https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png",
                                    "accessibilityText": "Google Logo"
                                },
                                "buttons": [
                                    {
                                        "title": "Button Title",
                                        "openUrlAction": {
                                            "url": "https://www.google.com"
                                        }
                                    }
                                ],
                                "imageDisplayOptions": "WHITE"
                            }
                        }
                    ]
                }
            }
        },
        "outputContexts": [],
        "followupEventInput": {}
    }
    

    查看this github 存储库,了解所有丰富响应的 JSON 格式。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-05-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多